A dependency management tool for PHP Composer 1: Download
curl -sS https://getcomposer.org/installer | php
Or
php -r "readfile('https://getcomposer.org/installer');" | php
2: move to the bin directory and use the composer command each time.
mv composer.phar /usr/local/bin/composer
View version
composer -V
3. composer. json install monolog in the project
The content of the composer. json file is as follows:
{ "require": { "monolog/monolog": "1.0.*" }}
Use composer install to install and create the vendor, monolog, and monolog directories in the current directory.
Composer generates a file named vendor/autoload. php. You can simply introduce this file and you will get a free automatic loading support.
This makes it easy for you to use third-party code. The project depends on monolog. you can start using this class library like this and they will be automatically loaded.
$log = new Monolog\Logger('name');$log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING));$log->addWarning('Foo');
4. download the thinkphp framework and install monolog.
composer create-project topthink/thinkphp myProjectNamecd myProjectNamevim composer.json
Find require
To:
"Require": {"php": "> = 5.3.0", "monolog/monolog": "1. 0. *"}, find http://packagist.phpcomposer.com to https://packagist.phpcomposer.com
Save and exit
composer install
The current directory will
Create the vendor, monolog, and monolog directories in the current directory.
You can introduce vendor/autoload. php in the framework entry file.
You can use it in the framework.
5. obtain the latest dependency version.
composer update
If you just want to update several packages
composer update vendor/package vendor/package2
Batch update with wildcards
composer update vendor/*