Use of PHP dependency management tool Composer

Source: Internet
Author: User
Tags composer install
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.