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.

Installing via Composer

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:

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: