Home > Article > Backend Development > PHP about the use of composer
This article mainly introduces the use of PHP composer, which has certain reference value. Now I share it with everyone. Friends in need can refer to it.
If the PHP command cannot be found, please indicate the environment variables. There is no php in it. Here you need to search for php on the disk and add the environment variable
composer is a dependent library of php. It will be safer and more efficient to download the third type of package here.
In the command line, first enter the root directory of the specified project (download a composer separately for each project).
The download command for windows is
php -r "readfile('https://getcomposer.org/installer');" | php
linux is:
curl -sS https://getcomposer.org/installer | php
After downloading, there should be one more composer.phar file in the directory, we can
php composer.phar
Call this file. If a row of usage lists appears, then the installation is successful.
Composer works like this:
There are two files, composer.json and composer.lock, in this directory.
Editing composer.json is to change the content of the dependent package, but this file is not downloaded as soon as it is saved. Instead, it is only saved in this file,
Through
php composer.phar install
is to lock the content in json into the composer.lock folder (the updates of file dependencies are all in composer.lock).
is to lock the content to be updated into the lock through hashing.
php composer.phar update
This sentence is to update the dependency package.
But the update here is to update all dependent packages, but if we only want to update a certain package individually,
We can use this command
composer require new/package
If this sentence If it cannot be installed, then change the sentence below
php composer.phar require new/package
is similar to
php composer.phar require qcloudsms/qcloudsms_php
which is to install Tencent’s SMS service
php composer.phar require phpmailer/phpmailer
In order to install PHPmailer
The added packages are all under ventor
The easiest way is to download the third-party library of PHPmailer from composer
Related recommendations:
Detailed explanation of the steps to create a Composer package in PHP
Installation of PHP dependency package Composer
Use Composer to automatically load the php namespace
The above is the detailed content of PHP about the use of composer. For more information, please follow other related articles on the PHP Chinese website!