欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

composer怎么把github上的包加载到项目vendor库里边。

1.在github申请账户,申请完成就可以创建项目了

2.创建一个composer.json文件:内容如下:

[html] view plain copy
 
  1. {  
  2.   "name": "zqy234/terrytest",  
  3.   "description": "Yii2 zqy234 terrytest",  
  4.   "keywords": [  
  5.     "yii2",  
  6.     "terrytest"  
  7.   ],  
  8.   "homepage": "https://github.com/zqy234/terrytest",  
  9.   "type": "yii2-extension",  
  10.   "license": "MIT",  
  11.   "support": {  
  12.     "source": "https://github.com/zqy234/terrytest"  
  13.   },  
  14.   "authors": [  
  15.     {  
  16.       "name": "terry water",  
  17.       "email": "zqy234@126.com"  
  18.     }  
  19.   ],  
  20.   "minimum-stability": "stable",  
  21.   "require": {  
  22.     "php": ">=5.4.0",  
  23.     "yiisoft/yii2": ">=2.0.6"  
  24.      
  25.   },  
  26.   "autoload": {  
  27.     "psr-4": {  
  28.       "terry\\": ""  
  29.     }  
  30.   },  
  31.   "config": {  
  32.     "process-timeout": 1800  
  33.   }  
  34. }  

 

3. 打开:https://packagist.org/packages/submit

把github的地址提交,提交成功后的界面:

 

4.到这里就提交成功了,您可以使用composer下载了:

 

[html] view plain copy
 
  1. composer require  zqy234/terrytest:dev-master  
[html] view plain copy
 
  1. [root@iZ942k2d5ezZ cc]# composer require  zqy234/terrytest:dev-master  
  2. ./composer.json has been updated  
  3. Loading composer repositories with package information  
  4. Updating dependencies (including require-dev)  
  5.   - Installing zqy234/terrytest (dev-master c80914f)  
  6.     Cloning c80914fc7dedc2f464f16fb0af5d3a843326bddb  
  7.   
  8. Writing lock file  
  9. Generating autoload files  


5.使用正式版本号(稳定版本号)

 

首先去github中:

 

 

 

 

然后再packagist中更新:

 

 

 

然后就可以更新了:

 

[html] view plain copy
 
  1. [root@iZ942k2d5ezZ cc]# composer require --prefer-dist zqy234/terrytest  
  2. Using version ^1.0 for zqy234/terrytest  
  3. ./composer.json has been created  
  4. Loading composer repositories with package information  
  5. Updating dependencies (including require-dev)  
  6.   - Installing yiisoft/yii2-composer (2.0.3)                 
  7.     Loading from cache  
  8.   
  9.   - Installing bower-asset/jquery (2.1.4)  
  10.     Loading from cache  
  11.   
  12.   - Installing bower-asset/yii2-pjax (v2.0.5)  
  13.     Loading from cache  
  14.   
  15.   - Installing bower-asset/punycode (v1.3.2)  
  16.     Loading from cache  
  17.   
  18.   - Installing bower-asset/jquery.inputmask (3.1.63)  
  19.     Loading from cache  
  20.   
  21.   - Installing cebe/markdown (1.1.0)  
  22.     Loading from cache  
  23.   
  24.   - Installing ezyang/htmlpurifier (v4.6.0)  
  25.     Loading from cache  
  26.   
  27.   - Installing yiisoft/yii2 (2.0.6)  
  28.     Loading from cache  
  29.   
  30.   - Installing zqy234/terrytest (1.0.0)  
  31.     Downloading: 100%           
  32.   
  33. Writing lock file  
  34. Generating autoload files  
  35. [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出来了。

 

 

基本的详细大致使用就这些

总之,可以快乐的,让别人下载自己的库包了

 

[html] view plain copy
 
  1. composer require --prefer-dist zqy234/terrytest  


 

 

 

 

 

 

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

来自 http://blog.csdn.net/terry_water/article/details/50477023
普通分类: