The official document gives two ways to install Yii2. One is to install through archive files, and the other is to install through composer. What are the specific differences between the two methods? We won’t discuss it here. You will understand it after the installation is complete.
I believe many friends want to learn Yii2, but most of them die at the beginning. It is said that everything is difficult at the beginning, and Yii2 undoubtedly proves this point better, giving you a hammer before you even start.
Preparation before installation
Installation through archive files
Let’s install Yii2 in a simple way first. The so-called simple way is actually a better way to install successfully, that is through archive files. Go ahead and install it! In other words, the basic framework has been compiled by others. You only need to download it, unzip it and configure it simply. In fact, you and I both understand why we need to install through archive files, because the other installation method failed, so we have no choice. Let’s take a look at the specific steps
1. Go to the official website to download an advanced template. We will not introduce the basic template. There is really nothing to introduce. Please refer to the location marked in the image below to download
(See original text for picture)
2. After decompressing, copy the advanced directory and place it in a web-accessible directory. The file name is advanced and should not be changed
3. If you are a Linux-like system, switch to the advanced directory and execute the php init command to initialize. If you are a Windows system, please double-click the init.bat file in the advanced directory
4. Next, we will be asked to select development environment 0 development environment 1 production environment. Here we select 0 development environment. After entering, press Enter. We will be asked to enter yes or no to confirm. Here we enter yes to confirm
5. Verify whether the installation is successful. At this time, you can enter http://localhost/advanced/frontend/web/
in the browser address bar.Look at the effect. A big Congratulations will be displayed on the interface, which means the installation is successful!
Install through Composer
If this is the first time you have heard of composer or the first time you use composer, I still recommend that you first understand what composer is and what this guy does. of. Here is a Composer Chinese document, I hope it will be helpful to you!
Generally, the data of the composer installation package (mainly zip files) is downloaded from github.com, and the metadata of the installation package is downloaded from packagist.org. As we all know, the connection speed of foreign websites is very slow, and they may be "walled" or even "non-existent" at any time, which will cause many people's composer to fail. We recommend that you refer to the Packagist/Composer China full image for the domestic image of composer. In this way, we will no longer be afraid of failure when installing or updating through composer. Of course, it still won't work when your Internet speed is very slow. Let’s take a look at the specific steps
[Considering that most domestic websites currently collect articles very frequently, and some even do not indicate the source of the original article, the original author hopes that readers can check the original article to prevent any problems and not update all articles to avoid misleading! ]
Continue reading