Home  >  Article  >  Development Tools  >  How to use Composer with Yii2

How to use Composer with Yii2

藏色散人
藏色散人forward
2019-08-13 14:28:003260browse

The following column composer usage tutorial will introduce how to use Composer in Yii2. I hope it will be helpful to friends in need!

How to use Composer with Yii2

#composer is a tool used by PHP to manage dependency relationships. You can declare the external tool libraries (libraries) you depend on in your project, and Composer will help you install these dependent library files

composer中文网

http ://www.phpcomposer.com/

Installation path

composer installation path https://getcomposer.org/download/

Installation under Windows

After the composer is successfully installed in windows, the composer.phar file will be generated in the C:\ProgramData\ComposerSetup\bin path.

Could not input open file: composer.phar appears during use. You should check the composer installation directory and environment variable configuration.

Actual operation

Before you need to execute the composer command, you can copy the composer.phar file to the project file and then execute it

So what we want Take the installation of Yii2-admin extension as an example https://github.com/mdmsoft/yii2-admin. We only need to copy composer.phar to the Yii2 project directory, then switch the command line to this directory and execute

php composer.phar require mdmsoft/yii2-admin "~1.0"

The sign of completion is that the vendor adds the mdmsoft source folder, which is the source file of yii2-admin.

The following are the relevant nodes of composer.json

"require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "*",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "guzzlehttp/guzzle": "~5.0",
        "mdmsoft/yii2-admin": "~1.0"
    },

The above is the detailed content of How to use Composer with Yii2. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:aliyun.com. If there is any infringement, please contact admin@php.cn delete