: This article mainly introduces the use of the PHP dependency management tool Composer. if you are interested in the PHP Tutorial, refer to it. Today I saw the dependency management tool in PHP, so I learned to try it out:
Environment: win7
I. Installation
1. confirm that the openssl module is enabled in PHP (used when using the https URL );
Modify the environment variable path and add c: \ xampp \ php
Open the command line and enter:
php -version
Display:
Run the cd command to change the current path to the project root directory, and then run the command to download and install:
php -r "readfile('http://getcomposer.org/installer');" | php
Here I use the http URL. If curl exists, run the following command:
curl -sS https://getcomposer.org/installer | php
The official website prompts you to download the installation package composer-setup.exe. Unfortunately, I saw it late and didn't try it out.
Add the composer. bat text file to the project root directory and execute the following command on the command line:
echo @php "%~dp0composer.phar" %*>composer.bat
Close and re-open the command line and enter the command:
composer -V
The output version is displayed.
II. example: the project must use the monolog library for output logs.
Create a composer. json file in the project and enter the following content:
{ "require": { "monolog/monolog": "1.0.*" }}
Run the following command on the cmd command line:
composer install
The required website may not be properly downloaded for some reasons. The prompt content may be:
Failed to enable cryptofailed to open stream: operation failed
At this time, you need to consider solving your network problems.
After the project is successfully run, the vendor folder appears in the project folder.
Example:
pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING));$log->addWarning('Foo');?>
III. others
Update itself:
Composer self-update
The above describes the use of the PHP dependency management tool Composer, including some content, and hope to be helpful to friends who are interested in the PHP Tutorial.