Composer Windows installation, Getting started with beginners
I. Pre-preparation:
1. Download the installation package, https://getcomposer.org/download/
2. Open Extension=php_openssl.dll in the php.ini document
3. Download Php_ssh2.dll, php_ssh2.pdb,http://windows.php.net/downloads/pecl/releases/ssh2/0.12/
4. Put Php_ssh2.dll, php_ssh2.pdb file in PHP ext folder
5. Restart apache,php
Two. Installation:
1. Click Next
2. Select the path to the folder where your Php.exe is located
3. Direct Click Next
4. Click Install
5. Click Finish
6. Open cmd and enter composer directly: The following indicates the successful installation
Three. Use:
For example, my project under the C:\Users\Administrator\Desktop\phpstudy\phpcode\20, plainly is in the ' 20 ' This folder,
I would like to use composer to manage components under this folder now, what should I do?
1. Create a Composer.json file in the ' 20 ' folder, which contains information about all of your components. The contents of this file are as follows:
I added three components that I wanted to use.
{" require": { "guzzlehttp/guzzle""4.2.*",//Front is the component name, followed by component version "league/ CSV"" 6.0.*",//php components, component name and version can be obtained from https://packagist.org/" spatie/string"" 1.8.* "}}
2. In the cmd command line, go to the ' 20 ' directory,
3. Execute the Composer install command on the cmd command line and he will download the 3 components in the Composer.json file under the ' 20 ' folder automatically.
The results are as follows:
As you can see, he automatically generates a vendor folder, and the components are all downloaded under vendor.
Four. Use of components:
1. First in the file to introduce vendor under the autoload.php file, which is the official automatic loading file.
2.new object, the method can be called.
Such as:
' vendor/autoload.php '; Introduction of automatic Loading file$client= \guzzlehttp\client (); Creating an object for a guzzlehttp component
$httpResponse = $client->options (); Calling methods
Five. It is very slow to download the components, which requires modifying the composer configuration file:
1. Enter the composer Config-l-G command in CMD to get the path to the composer configuration file.
The "Home" in the picture is followed by a path,
2. Open the Config.json file under path. Change the content to:
{ "config": { }, "repositories": [ {"type": "Composer", "url": "http://pkg.phpcomposer.com/repo/ packagist/"}, {" Packagist ": false} ]}
It is good to change the URL path to the available domestic path. A few more try to change a few.
Composer Windows installation, Getting started with beginners