woojean的博客 模仿、熟练、超越

将一个GitHub项目发布为Composer包的过程

2018-03-05

按psr-0标准开发并发布Github项目

主要就是命名空间、类名、文件路径的映射关系要正确,详略。

这里使用的项目是:https://github.com/woojean/RedisQueue

在项目中创建一个文件composer.json,内容如下:

{
    "name": "woojean/php-redis-queue",
    "description": "a redis queue of php",
    "license": "MIT",
    "keywords": ["redis queue php"],
    "version": "1.0.0",
    "authors": [
        {
            "name": "woojean",
            "email": "168056828@qq.com"
        }
    ],
    "require": {
        "php": ">=5.5.0"
    },
 
    "autoload": {
        "psr-0": {
            "Woojean\\RedisQueue": "src/"
        }
    }
}

注册Composer项目

packagist.org注册账号,详略。

点击Submit,输入项目地址: image

设置代码自动更新

image

To do so you can:

  • Go to your GitHub repository
  • Click the “Settings” button (是项目的setting,而不是Github的setting)
  • Click “Integrations & services”
  • Add a “Packagist” service, and configure it with your API token, plus your Packagist username (API token随便写)
  • Check the “Active” box and submit the form

You can then hit the “Test Service” button to trigger it and check if Packagist removes the warning about the package not being auto-updated.

image

发布项目

在Github中将项目pull release.


公众号
文章目录