Publish your own Composer package on Packagist

藏色散人
Release: 2020-02-11 13:54:26
forward
2650 people have browsed it

The following tutorial column from composer will introduce to you how to publish your own Composer package on Packagist. I hope it will be helpful to friends who need it!

Publish your own Composer package on Packagist

Explanation of terms:

Publish your own Composer package on Packagist

Brief description: I want to publish the project to packagist , you need to publish the project to github first (of course there is more than one option), and then log in to packagist to publish.

It can be understood that Packagist is the index and Github is the content provider

Steps:

1. Environment requirements (all official website downloads): git, composer, php,

2. Start packagist

Log in to https://packagist.org/ and click submit in the upper corner to submit the address of the git warehouse

Publish your own Composer package on Packagist

Add the GitHub Service Hook domain to point to the address of packagist to achieve automatic updates (when github changes, packagist will update accordingly).

Publish your own Composer package on Packagist

##The add packpackagist is as follows: User is the Packagist username and token is the ApiToken in Packagist. After the setting is completed, you can test whether it is successful

Publish your own Composer package on Packagist

3. Use the expansion pack

composer require xxxx/xxx               # 这时候会报错, Could not find package xxxx/xxx at any version for your minimum-stability (stable). Check the package。。。猜测是我的composer使用的国内镜像,可能是没有同步的原因,使用这个命令把“源”改回去还是不行。
composer config repo.packagist composer https://packagist.org  # 继续猜测,原来我的组件还没有在github上发布正式,这个时候还是开发版本dev-master.应该加上dev-master版本。
composer require xxxx/xxx:dev-master     # 成功
Copy after login

Because we all know The reason is that even the code warehouse has to be blocked. Wait a few hours and try again. Then my knowledge of the network is really poor. Fighting~

For more composer-related technical articles, please visit

composer Column: https://www.php.cn/tool/composer/

The above is the detailed content of Publish your own Composer package on Packagist. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template