uses the following two websites:
https://github.com/
https: //packagist.org
(0)Article structure:
1 Build:
- Create github project;
- Submit to packagist;
2 Use;
(1)Build
A composer package is a github repository plus a composer.json;
My hello_world project Screenshot:
git log screenshot. See clearly that tag is added (reference: https://docs.phpcomposer.com/... A tag must be added to automatically generate a stable version.
How to submit to packagist, see https://packagist.org/Homepage:
Follow the registration and operation:
Verify that if there is no problem, you will see it on the package page. Pay attention to the package version in the lower right corner. My project has three version numbers (version Description of the number generation rules: the git master branch automatically generates the "dev-master" version, and each of the two tags generates a version number "1.0.0" and "1.0.1")
(2) Use
Then you can download the package and use it. Take my project as an example:
composer create-project linzh/hello_world , so that it will download my latest version by default stable version (non-dev);
If you want to download other versions, you can specify it yourself, eg:composer create-project linzh/hello_world=dev-master, so that the "dev-master" version will be downloaded
If you do not add a tag, you must also specify the version number yourself, otherwise an error will be reported