Installing Yii PHP Framework
You can install Yii in two ways, using Composer or by downloading an archive file. The former is the preferred way, as it allows you to install new extensions or update Yii by simply running a single command.
Note: Unlike with Yii 1, standard installations of Yii 2 result in both, the framework and an application skeleton being downloaded and installed.
If you do not already have Composer installed, you may do so by following the instructions at getcomposer.org. On Linux and Mac OS X, you’ll run the following commands:
curl -s http://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
On Windows, you’ll download and run Composer-Setup.exe.
Please refer to the Composer Documentation if you encounter any problems or want to learn more about Composer usage.
If you had Composer already installed before, make sure you use an up to date version. You can update Composer by running
With Composer installed, you can install Yii by running the following commands under a Web-accessible folder:
composer global require "fxp/composer-asset-plugin:1.0.0-beta3" composer create-project --prefer-dist yiisoft/yii2-app-basic basic
The first command installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all. The second command installs Yii in a directory named
basic. You can choose a different directory name if you want.
Note: During the installation it may happen that Composer asks for login credentials for your Github account because it hits the Github API rate-limit. This is normal because Composer needs to retrieve a lot of information for all the packages from Github. Logging in to Github increases the API rate-limit so Composer can go on with its work. For more details, please refer to the Composer documentation.
Tip: If you want to install the latest development version of Yii, you may use the following command instead, which adds a stability option:
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
Note that the development version of Yii should not be used for production as it may break your running code.