composer上发布项目Packgist

2018-07-03  本文已影响0人  孤独而灿烂的郑金叹
GitHub帐号
Composer程序(确认你已经安装)
Packagist帐号(用GITHUB账号登录)
  1. 本地初始化conposer.json
    $ cd ~/path/...
    $ composer init
  2. 初始化composer文件,推送修改到github,如果你项目在github,这一步刻意忽略。
  1. 镜像包发布到packgist
    使用Github账户登录Packgist,由于本身composer就是从github发展而来的。
    找到submit,用你的项目仓库地址将镜像包发布提交。

  2. 配置GitHub和Packagist之间的自动更新钩子,根据向导,复制自己的packagist的api token,然后去GitHub配置好仓库的钩子服务(此处在测试器,github集成与服务已经逐渐弃用)

D:\phpStudy\PHPTutorial\WWW>composer create-project zlqbook/housespider
Installing zlqbook/housespider (0.1.0)
  - Installing zlqbook/housespider (0.1.0): Downloading (100%)
Created project in D:\phpStudy\PHPTutorial\WWW\housespider
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 65 installs, 0 updates, 0 removals
  - Installing yiisoft/yii2-composer (2.0.6): Loading from cache
  - Installing bower-asset/jquery (3.2.1): Loading from cache
  - Installing bower-asset/bootstrap (v3.3.7): Loading from cache
/*成功部分省略*/
codeception/base suggests installing codeception/specify (BDD-style code blocks)
codeception/base suggests installing flow/jsonpath (For using JSONPath in REST module)
codeception/base suggests installing league/factory-muffin (For DataFactory module)
codeception/base suggests installing league/factory-muffin-faker (For Faker support in DataFactory module)
codeception/base suggests installing phpseclib/phpseclib (for SFTP option in FTP Module)
codeception/base suggests installing stecman/symfony-console-completion (For BASH autocompletion)
codeception/base suggests installing symfony/phpunit-bridge (For phpunit-bridge support)
Generating autoload files
    {
        "psr-4": { "Rivsen\\Demo\\": "src" }
    },

看一个具体的composer.json文件:

{
    "name": "zlqbook/housespider",
    "description": "douban spdider base Yii 2 ",
    "keywords": ["yii2", "framework", "advanced", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
// 支持,这些信息会在packgist项目首页显示
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
  /*依赖*/
    "require": { 
        "php": ">=5.4.0",
        "yiisoft/yii2": "~2.0.6",
        "yiisoft/yii2-bootstrap": "~2.0.0",
        "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0"
    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.0.0",
        "yiisoft/yii2-gii": "~2.0.0",
        "yiisoft/yii2-faker": "~2.0.0",
        "codeception/base": "^2.2.3",
        "codeception/verify": "~0.3.1"
    },
    "config": {
        "process-timeout": 1800,
        "fxp-asset": {
            "enabled": false
        }
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ]
}
/*创建分支*/
$ cd ~/work/github/hello-world
$ git branch
//创建分支 0.1
git checkout -b 0.1
//提交分支
$ git add .
$ git commit -m 'update readme'
$ git push origin 0.1
发布版本
$ git tag 0.1.0
$ git push --tags
上一篇下一篇

猜你喜欢

热点阅读