How to install yii2 in composer?
1. Install composer
Mine is win7 (I’m used to it after using it for 8 years), download address: https://getcomposer.org/download/, very simple English , don’t say you can’t understand, you may not be good at English, but you must remember these words
: download, windows, linux, install, setup.
Okay, download it and install it. During this period, your php version directory will be automatically selected. You should make sure that the php version is greater than 5.4.?
Then you should pay attention to whether composer is installed. Which directory is it in? I installed it to composer on the c drive. It will be automatically added to the system variables here, so you don’t have to add it manually.
Related recommendations: 《composer command》
2.cmd operation
①Open cmd and output the composer -V command to check whether the installation is successful
②Switch to the previous composer installation directory. You may not need to switch because it was added to the system variables before, but just in case, switch to the composer directory
③ Change the downloaded mirror address to the domestic mirror, otherwise it will be miserable when downloading!
Use the following command: composer config -g repo.packagist composer https://packagist.phpcomposer.com Enter
④Download Yii2
At this time you can use cmd Change the directory to the folder in the root directory of the local server, for example: D:\phpstudy\WWW\php\demo
Then: composer global require "fxp/composer-asset-plugin:~1.1.1 " Press Enter
Then: composer create-project --prefer-dist yiisoft/yii2-app-basic basic Press Enter (I installed the basic version here)
At the third red line, you are asked to enter a Token (from Github), so you have to go to Github to get a Token:
The steps are as follows:
Log in to your Github--- >Your avatar in the upper right corner--->Settings--->The last Developer settings in the left sidebar--->Personal access tokens
--->Generate new in the left sidebar token, then a page will pop up, fill in your github password, then fill in the description of the token, check all below, submit, and generate the token.
After filling in the token in cmd, the download will start, and the download will be completed in about 10 minutes.
When you open the demo folder, you will see an additional basic folder below. When you open it, you will see:
In this way, the Yii2 framework It is downloaded to your project. The entry file is web/index.php. Then, open the browser and enter the path of the entry file under the project:
http://localhost/php/demo/basic/ web/index.php, and then you can see the page you saw at the beginning of the article!
The above is the detailed content of How to install yii2 in composer. For more information, please follow other related articles on the PHP Chinese website!