企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 示例: [一步一步创建自己的composer包](https://www.cnblogs.com/gelu/p/9732649.html) # 构建之前 1. 申请github账号,并建好一个repositories。 2. 用github登录packageList. # 创建包 ## 初始化仓库 ~~~ mkdir -p /www/plan cd /www/plan echo "# plan" >> README.md git init git add README.md git commit -m "first commit" git remote add origin git@github.com:lujiang/plan.git git push -u origin master ~~~ ## `composer init`构建composer.json ~~~ { "name": "lujiang618/plan", "description": "plan", "type": "project", "licence": "MIT", "authors": [ { "name": "lujiang", "email": "531432594@qq.com" } ], "require": { "php":">=7.0.0" }, "autoload": { "psr-4":{ "Tools\\":"src/Tools" } } } ~~~ ## 构建包 1.按照autoload中设置的,在根目录下建一个Tools的目录 2.在Tools目录写一个tools类 ~~~ <?php /** * Created by PhpStorm. * User: lujiang * Date: 2018/9/30 * Time: 15:57 */ namespace Tools; class Tools { public function __construct() { } public static function hi() { echo 'hi'; } } ~~~ 3.在根目录写一个测试类hi.php ~~~ <?php /** * Created by PhpStorm. * User: lujiang * Date: 2018/9/30 * Time: 16:06 */ require_once './vendor/autoload.php'; use Tools\Tools; echo Tools::hi(); ~~~ 4.执行`composer install`生成vendor目录 5.执行测试类,输出hi。如此一个包构建完成了 ~~~ cd /www/plan php hi.php ~~~ 6.提交代码到github ~~~ git add . git commit -am 'first' git push git tag -a v0.0.1 -m "first version" git push origin v0.0.1 ~~~ #### 在github上发布版本,找到release,执行发布(勾上\[This is pre-release\]) #### 在packagist上submit package。并在profile里面获取token。在github的settings的Installed GitHub Apps添加packagist的service