packagist

  1. 登录https://github.com

  2. 点击“Start a project”创建一个项目

  3. 输入项目名称、描述(Description),设为public,并用README初始化这个项目

  4. 点击Create repository完成创建

  5. 进入https://github.com/[Owner]/[Project name]

  6. 点击Clone or download复制链接地址

  7. 在个人电脑下载这个项目

     git clone https://github.com/[Owner]/[Project name].git
    
  8. 进入项目 根目录 执行

     composer init
     # 所有选项选择默认,或者参考如下配置:
     # 这里一定注意: name值必须是小写!!!
     {
       "name": "2233466866/book",
       "type": "library",
       "description": "FastDFS client engine.",
       "keywords": [
         "DFS",
         "FastDFS"
       ],
       "homepage": "https://github.com/2233466866/book",
       "license": "MIT",
       "support": {
         "issues": "https://github.com/2233466866/book/issues"
       },
       "authors": [
         {
           "name": "耿志环",
           "email": "2233466866@qq.com",
           "homepage": "http://weibo.com/u/3215774830/home"
         }
       ],
       "require": {
         "php": ">=7.0.1"
       },
       "require-dev": [],
       "suggest": {
         "ext-fastcommon": "https://github.com/happyfish100/libfastcommon/releases",
         "ext-fastdfs_client": "https://github.com/happyfish100/fastdfs/releases"
       },
       "autoload": {
         "classmap": [
           "src/"
         ]
       }
     }
    
  9. composer.json有多种方式引入类文件

     "autoload": {
         "psr-0": {
             "Package1\\": "package1/",
             "Package2\\": "package2/"
         },
         "psr-4": {
             "Package3\\": "package3/",
             "Package4\\": "package4/"
         },
         "classmap": [
             "Package5/",
             "Package6/"
         ],
         "include-path": [
             "Package7/",
             "Package8/"
         ],
         "files": [
             "Package9/MyClass1.php",
             "Package9/MyClass2.php",
             "Package9/MyClass3.php"
         ]
     }
    
  10. 在根目录创建LICENSE,仅供参考

     Copyright (c) 2016-2017 Zhihuan Geng
    
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to deal
     in the Software without restriction, including without limitation the rights
     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     copies of the Software, and to permit persons to whom the Software is
     furnished to do so, subject to the following conditions:
    
     The above copyright notice and this permission notice shall be included in all
     copies or substantial portions of the Software.
    
     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     SOFTWARE.
    
  11. 提交项目文件的更新

     git status
     git commit -a -m "更新项目"
     git checkout -b test
     git push origin test:test
    
  12. https://github.com/[Owner]/[Project name]添加Pull request并接受提交

  13. https://github.com/[Owner]/[Project name]点击: release->Draft a new release->publish release, 创建1.0发行版本

  14. 登录https://packagist.org,点击submit

  15. 在Repository URL输入https://github.com/[Owner]/[Project name]

  16. 点击Check检查,防止与其它项目重复,没有问题则Submit该项目

  17. 登录https://packagist.org,点击用户名->Profile->[Owner]/[Project name]

  18. 会看到你的项目没有开启自动更新,点击“GitHub Service Hook”

  19. 根据“How to update packages?”文档的提示开启更新,如看不懂英文文档,参照下面步骤

    1. https://github.com/[Owner]/[Project name],点击:

      1. Settings->Integrations & services->添加Packagist->Packagist
    2. 填写表单中相关的选项

      1. 其中User为https://packagist.org用户名

      2. 其中Token为https://packagist.org首页->用户名->Profile->中的隐藏信息,需要点击“Show API Token”显示

      3. 其中Domain为空或“https://packagist.org”

    3. 填写完成后提交表单,即可完成自动更新

  20. 尝试安装

     composer require [Owner]/[Project name]
     composer update nothing
     composer require [Owner]/[Project name]
    
@耿志环 2012-∞ 冀ICP备17033181号, powered by Gitbook修订: 2018-06-20 11:11:01

results matching ""

    No results matching ""