In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the use of composer in php". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what is the use of composer in php"?
Php composer usage: 1, install composer.json;2, add packages to the existing composer.json; 3, update through "composer update"; 4, create projects with dependent packages.
This article operating environment: windows7 system, PHP7.1&&Composer version 2.0, Dell G3 computer.
What is the use of php composer?
The operation of composer is very complicated, which is usually not needed, and it will be difficult to find it at 01:30.
Daily operation, let's go
Part one: install composer.json
Composer init
This command creates a composer.json file, or you can manually create edits, declaring dependencies and versions.
For more information on composer.json content format, please see
{"require": {"monolog/monolog": "1.0.*"}} composer install
Create and fill in the composer.json and execute the install command for the first installation
The first installation will check the listed software packages, dependencies, etc., to find the appropriate (through constraints) version number
A lock file composer.lock will be generated after that
The exact version number of each package is recorded in the lock file.
When you perform the installation again, you will check whether the lock file exists, and install it directly as specified in the lock file.
Part 2: add a package to the project (composer.json already exists)
Composer require dependency package / dependency package: version number
You can also add multiple spaces to open eg: doctrine/orm:1.0.0 at the same time
Part III: update
Composer update
This command ignores the lock file, updates the dependencies listed in composer.json, and regenerates the lock file
Part IV: create a project with a dependency package
Composer create-project dependent package / dependent package path version version
Note that when you create a project with a package, you can also specify a version, but the version is constrained by the third parameter, and the second parameter is the project path (relative). No specified version the latest version is installed by default
Eg: laravel/laravel path 5.8.0
Appendix
Switch Chinese mirror sources
Composer config-g repo.packagist composer https://packagist.phpcomposer.com
In a production environment, the installation initialization project uses the-o option. See the official documentation for details.
-optimize-autoloader (- o):
Converting PSR-0/4 autoloading to classmap results in faster loading support. This is recommended especially in a production environment, but because it takes some time to run, it is not used as the default.
At this point, I believe you have a deeper understanding of "what is the use of composer in php". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.