前提:
你須要收github和Packagist帳號
github地址:https://github.com
Packagist地址:https://packagist.orggit
一:將你的composer包代碼上傳到github上
如何上傳代碼到github上能夠參考個人:github 簡單使用
若是你須要能夠實現composer下載,那麼你的composer包中必需要有composer.json文件
composer.json文件基本格式你能夠按照以下格式編寫:github
{ "name": "huaweichenai/baidu-discern", "description": "Baidu realizes picture recognition text package(百度實現圖片識別文字包)", "keywords": ["yii2","baidu","discern","extension"], "type": "yii2-extension", "license": "BSD-3-Clause", "authors": [ { "name": "huaweichenai", "email": "243681093@qq.com", "homepage": "https://www.wj0511.com/" } ], "require": {}, "minimum-stability": "dev", "autoload": { "psr-4": { "huaweichenai\\discern\\": "src" } } }
二:將composer包上傳到packagistjson
1:登陸packagist而後點擊右上角的submit按鈕yii2
2:在輸入框中輸入你的github代碼倉庫地址,而後點擊checkcomposer
若是出現錯誤根據錯誤提示解決,沒有錯誤點擊submityii
等到submit執行事後出現以下界面表示你的composer包已經上傳packagist上了ui
雖然咱們已經將comspoer包上傳到packagist上了,可是咱們在本地安裝咱們的composer包時仍是會報錯的spa
這是由於咱們沒有在github上指定版本的緣由,若是咱們不想在github上指定版本,這時候咱們能夠執行3d
composer require huaweichenai/baidu-discern "dev-master" #huaweichenai/baidu-discern是個人composer包
這時候就能夠將咱們的composer包下載下來了code
咱們也能夠在github上指定版本,那麼如何在github上指定版本呢?
1:點擊releases
2:點擊Create a new release
3:發佈一個版本
4:發佈一個版本以後咱們在packgist上點擊update進行更新,這時候咱們就能夠在本地不進行指定版本安裝了
composer require huaweichenai/baidu-discern
將發佈包上傳到 Packagist 後可能須要幾分鐘才能夠使用,若是出現問題,等過幾分鐘在進行安裝就能夠了