Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Composer in Yii2

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use Composer in Yii2. It is very detailed and has a certain reference value. Friends who are interested must finish it!

How to understand Composer?

If we use Composer, we should first know what it is and what it is mainly used for. We can understand Composer as a PHP package management tool to manage the Yii2-related plug-ins we use.

Install Composer

1. Install under liunx

Download the composer.phar executable file and execute it with the command php composer.phar.

2. Windows installation

Download Composer-Setup.exe and double-click to install it. For more information on how to use it, refer to the steps of installing yii2 under win7 system.

Execute the command using composer under linux: php composer.phar require-- the red part of the prefer-dist yiisoft/yii2-redis is the directory and name of the plug-in.

The execution command using composer under windows: the composer global require "fxp/composer-asset-plugin:1.2.0" red part is the name of the plug-in.

Composer in Yii2

When we open the directory after we have installed Yii2, we will see the composer.json file in the installation directory, which contains the required information and dependent libraries. Go to the root directory of the project and execute php composer .phar install to download the dependent library files and store them in the vendor folder, with an additional composer.lock lock file. Every time we need to install the required Yii2 plug-in, open composer.json and find "require" as follows:

"require": {"php": "> = 5.4.0", "yiisoft/yii2": "= 2.0.10", "yiisoft/yii2-bootstrap": "*", "yiisoft/yii2-swiftmailer": "*", "qiniu/php-sdk": "*", "dmstr/yii2-adminlte-asset": "2.*", "2amigos/yii2-file-upload-widget": "~ 1.0"," mdmsoft/yii2-admin ":" = 2.7" "yiisoft/yii2-jui": "= 2.0.6", "linslin/yii2-curl": "*", "bower-asset/jquery": "1.12.*@stable", "bower-asset/layer": "3.*", "bower-asset/jquery-cookie": "1.4.*", "wdteam/yii2-webuploader": "*"}

Add one to it, and then execute php composer.phar update (update will update everything, if you only want to update the newly added plug-in to execute php composer.phar update foo/bar).

The above is all the content of the article "how to use Composer in Yii2". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report