下面由composer使用教程欄目給大家介紹如何在Packagist發(fā)布自己的Composer包,希望對需要的朋友有所幫助!
名詞解釋:
簡要說明:想要把項目發(fā)布到packagist上,需要先將項目發(fā)布到github上(當(dāng)然不止此一種選擇),之后再登陸packagist發(fā)布。
可以這么理解Packagist是索引,Github是內(nèi)容提供方
步驟:
一、環(huán)境要求(都官網(wǎng)下載):git、composer、php,
二、開始packagist
登錄https://packagist.org/ 點擊由上角的submit提交git倉庫的地址
添加 GitHub Service Hook domain 指向packagist的地址,實現(xiàn)自動更新(github有變化的時候,packagist跟著更新)。
其中的add packpackagist如下:User為Packagist用戶名token為Packagist中的ApiToken,設(shè)置完成之后可以test 是否成功
三、使用擴展包
composer require xxxx/xxx # 這時候會報錯, Could not find package xxxx/xxx at any version for your minimum-stability (stable). Check the package。。。猜測是我的composer使用的國內(nèi)鏡像,可能是沒有同步的原因,使用這個命令把“源”改回去還是不行。 composer config repo.packagist composer https://packagist.org # 繼續(xù)猜測,原來我的組件還沒有在github上發(fā)布正式,這個時候還是開發(fā)版本dev-master.應(yīng)該加上dev-master版本。 composer require xxxx/xxx:dev-master # 成功
因為眾所周知的原因,連代碼倉庫也要被墻,等幾個小時再試試看吧,然后自己對網(wǎng)絡(luò)這方面的知識實在是太差了,fighting~