使用GitHub登录packageLIst
# 1 进入一个空目录
mkdir abell && cd abell
新建一个空GitHub项目,直接使用生成的内容在空目录初始化git
# 2 初始化git项目
echo "# test_composer" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/RoseKissYou/test_composer.git
git push -u origin main
初始化composer配置
# 3 初始化composer
配置
composer init
# 添加包名 默认回车就可以了
# 添加描述
这里生成了一个简单的composer包
{
"name": "abell/test_composer",
"description": "test composer",
"keywords": [
"tool",
"testcomposer",
"abell"
],
"authors": [
{
"name": "rosekissyou",
"email": "onebenbenxiong@163.com",
"role": "Developer"
}
],
"license": "Apache2",
"require": {},
"autoload": {
"psr-4": {
"Abell\\": "src/Abell"
}
}
}
代码编辑好了之后提交到GitHub
接下来就在GitHub上提交一个 release
提交完后如图
接着去 https://packagist.org/ 上 https://packagist.org/packages/submit
submit package
填上自己的GitHub网站 https://github.com/RoseKissYou/test_composer/
接下来进行简单的测试就可以了
composer require abell/test_composer
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace App\Controller;
use Abell\AeTool;
class IndexController extends AbstractController
{
public function hello()
{
AeTool::hello();
return 11;
}
}
这样就创建了自己的composer包