First of all, what is called composer?
OK, direct Baidu Wikipedia. Http://baike.baidu.com/view/1657652.htm
So how do I install composer under Windows?
Windows executes commands in a way that is less convenient than Linux. So we have to set the PHP environment variables, so that PHP can be run through DOS.
1. Environment variables, advanced system settings, properties, My Computer (right-click), select Path, edit, append later
;D: \xampp\php
Alt+r->cmd Open the DOS window and execute php-v. If there is an error in the middle, prompt a series of DLLs not found, modify php.ini,
Set the value of the Extension_dir to the absolute path, Extension_dir = "D:\xampp\php\ext", I've got a browscap.dll. Error hint not found, find Browscap in php.ini, and change its value to absolute path value
If it doesn't go wrong. To execute the PHP-V, the following results should be obtained:
2. Turn on SSL extensions
Modify php.ini, open extension = Php_openssl.dll
3. Go to the PHP directory and execute the PHP command.
It is recommended that by modifying the form of the registry, you can right-click on the file to be entered, and go directly to the cmd command of the file without executing cd/d every time D:/xampp/htdocs
Create a new file and paste the code:
Windows Registry Editor Version 5.00
[Hkey_classes_root\folder\shell\cmd]
@= "cmd fast track"
[Hkey_classes_root\folder\shell\cmd\command]
@= "cmd.exe/k cd%1"
Save As Xx.reg, run, click Yes, then find a folder, right click, you will see a CMD fast-track operation,
Back to the point: Go to Project file Htdocs, enter in DOS
Php-r "eval ('?> '. file_get_contents (' Https://getcomposer.org/installer '));"
Wait a moment and you'll see the following prompt:
4. In your project file, create a new Xx.bat file, and edit the following:
@ECHO OFF
SET subdir=%~dp0
PHP%subdir%\composer.phar%*
Then execute it. This file is to define the current path as composer, and of course you can not execute the file.
5. Here, the composer is basically installed. So next we're going to install the expansion pack,
Open the Composer.json in Htdocs and enter the extension we want to install:
The format is roughly as follows:
{
"Require": {
"Chrisboulton/php-resque": "1.2",
"lisachenko/go-aop-php": "*",
"Monolog/monolog": "1.2.*"
}
}
6. If the fourth step file is executed, execute the composer install directly under the Htdocs directory
If the file for step fourth is not executed, PHP Composer.phar install is required
OK, the installation here is complete, the expansion package, also downloaded. Htdocs will be more than a vendor folder, Open will find, chrisboulton,lisachenko,monolog three more folders. Now let's take a look at automatic loading ...
We need to use the expansion pack again, require_once Root_path. ' vendor/autoload.php ';
You can then call the class name in the extension package directly.
Examples are as follows:
Require_once Root_path. ' vendor/autoload.php ';//root_path is the root directory
$redis = Resque::redis ();//Call vendor/chrisboulton/php-resque/lib/resque.php's class name directly here, without introducing the file
Var_dump ($redis);
This redis variable is a Redis class for Php-resque