Composer is a package dependency management tool for PHP. We can declare the external tool library we rely on in the project. Composer will help you install these dependent library files. Use a command. We can refer other people's excellent code to our project. Composer is not installed globally by default. It is installed based on a directory (such as vendor) of the specified project. Composer requires PHP 5.3. 2 + or above. You need to turn on openssl. Composer runs on Windows, Linux, and OSX platforms.
Composer is a popular PHP package dependency management tool. It has replaced the PEAR package manager. It is necessary for PHP developers to master Composer.
Composer is simple for users. Download the required code package to the vendor directory through a command. Developers can import packages and use them.
The key lies in the composer.json defined by your project. It can define the packages (possibly multiple) that the project needs to rely on. Dependent packages may depend on other packages. This is the benefit of components. You don't have to worry about this. Composer will download what you need. It all depends on the definition of composer.json.
We will find in the process of using composer. When we execute commands such as composer update. There will be one more composer.lock file. What is this document for? This file is used by the management package version. When we use the composer update command. Composer depends on the package version of composer. Json. It generates the corresponding composer.lock file. The next time we execute the composer command. It reads the contents of the composer.lock file.
Depending on the package dependency in the composer.json configuration file and the corresponding version. Composer update will update the version. This command updates all packages to the latest version. It needs to be used carefully in actual projects. Particularly in the production environment.
According to the package dependency configuration in the composer.json configuration file. We learned how to install the corresponding package. This command may not need to be based on the configuration file. You can install a package. After installation. The corresponding dependency configuration is added to the composer.json configuration file.
The composer remove command removes the specified package dependency. For example, we do not need to rely on a package. You can use the command + package name. After executing the command. Package dependencies in the configuration file are removed. There is no need for us to operate manually.
The composer show command is used to view information about packages already installed.
Compose is transparent to that user. We need to understand the concept behind it. Its birth was not accidental. This is due to the rapid development of Github. The PHP language is becoming more modern.