Before applying, make sure you have composer installed.
Installation procedure, you can refer to http://docs.phpcomposer.com/00-intro.html
1) Configure the Composer.json file
To start using Composer in your project, you only need a Composer.json file. This file contains the dependencies of the project and some other metadata.
{ "name": "Lizhibin331313869/test", GitHub account name "version": "0.1.0", //Project version " Require": { //require key tells Composer which packages your project needs to rely on. "Monolog/monolog": "1.2.*" }}
After the configuration is complete, execute composer install, after execution completes, will generate the vendor folder in the current directory, as well as the Composer.lock file, the lock file contains the version of the dependent package just downloaded, ensure that each project installation is using the same version of the dependency package.
This means that anyone who builds a project will download the exact same dependency as the specified version. Your continuous Integration server, production environment, other developers on your team, everything, everyone uses the same dependencies to mitigate the impact of potential errors on your deployment. Even if you are developing your project on your own, you can rest assured that you will be able to continue working even if you have already released many new versions of your dependencies since then within six months.
2) Use Monolog
For the library's automatic loading information, Composer generates a vendor/autoload.php file. You can simply introduce this file and you will get a free auto-load support.
Use Monolog\logger;use Monolog\handler\streamhandler; require ' vendor/autoload.php '; $loggerModel =new Logger (' test '); $log = new Logger (' name '); $log->pushhandler (new Streamhandler (' D:\test\log\monolog.txt ', logger::warning));//Add Records to the log$log->addwarning (' Foo ', Array ( ' Foo is null! '); $log->adderror (' Bar ');
Reference: http://docs.phpcomposer.com/01-basic-usage.html
The above describes the composer application (i) automatic loading, including the content of the Require,github, I hope that the PHP tutorial interested in a friend helpful.