PHP relies on the use of management tools composer

Source: Internet
Author: User
Tags composer install
Today I saw a dependency management tool that introduced PHP, so we learned to try it out:

Environment: Win7

First, installation

1. Verify that PHP is enabled with the OpenSSL module (using HTTPS URLs);

Modify environment variable path, join c:\xampp\php

Open the command line and enter:

Php-version

Show:


Use the CD command to change the current path to the project root, and then run the command to download the installation:

Php-r "ReadFile (' Http://getcomposer.org/installer ');" | Php
I'm using the HTTP protocol URL here. If you have curl, you can also use the following command:
Curl-ss Https://getcomposer.org/installer | Php
Official website tips can also download the installation package Composer-setup.exe, unfortunately I see late, no trial.

To the project root, add the Composer.bat text file and execute it at the command line:

echo @php "%~dp0composer.phar"%*>composer.bat
Close and reopen the command line and enter the command:
Composer-v
You can see the version information for the output.

example, the project needs to use the output log library Monolog.

Create a Composer.json file within the project and enter the content:

{"    require": {        "Monolog/monolog": "1.0.*"    }}
Execute at cmd command line:
Composer Install
The required URLs may not be downloaded properly for some reason. It may be prompted by the following:
Failed to enable cryptofailed to open stream:operation Failed

You should consider solving your network problems at this time.

After successful operation, the Vendor folder appears in the project folder.

Examples of Use:

 
  Pushhandler (New Monolog\handler\streamhandler (' App.log ', monolog\logger::warning)); $log->addwarning (' Foo ');? >

Third, other

Update itself:

Composer Self-update

The above describes the use of PHP dependency management tool composer, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.