[PHP] 发布一个类库到composer

2021-05-18 12:01:15 浏览数 (1)

首先有github仓库 , 仓库的结构可以是这样

composer.json文件可以类似这样

代码语言:javascript复制
{
    "name": "taoshihan/php-router",
    "license": "Apache-2.0",
    "description": "php simple router",
    "type": "library",
    "authors": [
        {
            "name": "taoshihan1991",
            "email": "630892807@qq.com"
        }
    ],
    "autoload": {
        "psr-4": {
            "taoshihan\": "src"
        }
    }
}

github地址:

https://github.com/taoshihan1991/php-router

需要打了tag

git tag v1.0

git push origin v1.0

在这个网站注册 , 或者github直接登录 , 点击submit , 输入自己的仓库就ok了

https://packagist.org/

别人使用的时候就可以 composer require 仓库

composer require taoshihan/php-router

0 人点赞