1.在github申请账户,申请完成就可以创建项目了
2.创建一个composer.json文件:内容如下:
{
"name": "zqy234/terrytest",
"description": "Yii2 zqy234 terrytest",
"keywords": [
"yii2",
"terrytest"
],
"homepage": "https://github.com/zqy234/terrytest",
"type": "yii2-extension",
"license": "MIT",
"support": {
"source": "https://github.com/zqy234/terrytest"
},
"authors": [
{
"name": "terry water",
"email": "zqy234@126.com"
}
],
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.6"
},
"autoload": {
"psr-4": {
"terry\\": ""
}
},
"config": {
"process-timeout": 1800
}
}
3. 打开:https://packagist.org/packages/submit
把github的地址提交,提交成功后的界面:
4.到这里就提交成功了,您可以使用composer下载了:
composer require zqy234/terrytest:dev-master
[root@iZ942k2d5ezZ cc]# composer require zqy234/terrytest:dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing zqy234/terrytest (dev-master c80914f)
Cloning c80914fc7dedc2f464f16fb0af5d3a843326bddb
Writing lock file
Generating autoload files
5.使用正式版本号(稳定版本号)
首先去github中:
然后再packagist中更新:
然后就可以更新了:
[root@iZ942k2d5ezZ cc]# composer require --prefer-dist zqy234/terrytest
Using version ^1.0 for zqy234/terrytest
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing yiisoft/yii2-composer (2.0.3)
Loading from cache
- Installing bower-asset/jquery (2.1.4)
Loading from cache
- Installing bower-asset/yii2-pjax (v2.0.5)
Loading from cache
- Installing bower-asset/punycode (v1.3.2)
Loading from cache
- Installing bower-asset/jquery.inputmask (3.1.63)
Loading from cache
- Installing cebe/markdown (1.1.0)
Loading from cache
- Installing ezyang/htmlpurifier (v4.6.0)
Loading from cache
- Installing yiisoft/yii2 (2.0.6)
Loading from cache
- Installing zqy234/terrytest (1.0.0)
Downloading: 100%
Writing lock file
Generating autoload files
[root@iZ942k2d5ezZ cc]#
这样就安装成功了。
6.版本号自动更新(github和packagist之间)
访问:https://packagist.org/profile/
获取api token
详细说明地址:https://packagist.org/about
填写的url的格式:https://packagist.org/api/bitbucket?username=USERNAME&apiToken=API_TOKEN
可以用:
curl -XPOST -H'content-type:application/json' 'https://packagist.org/api/update-package?username=USERNAME&apiToken=API_TOKEN' -d'{"repository":{"url":"PACKAGIST_PACKAGE_URL"}}'来检测。
测试:
在github那边增加一个稳定版本号
然后再 https://packagist.org/packages/zqy234/terrytest#1.0.1
发现:1.0.1出来了。
基本的详细大致使用就这些
总之,可以快乐的,让别人下载自己的库包了
composer require --prefer-dist zqy234/terrytest