- Download the composer from getcomposer.org
- When you install the composer, It will ask to choose the "php.exe" file.
- on Linux or Mac, run the following commands:
curl -s http://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
- To check the composer installation, Type the below code in command prompt
With Composer installed, you can install Yii by running the following commands under a Web-accessible folder:
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.
composer global require "fxp/composer-asset-plugin:1.0.0-beta2"
Installing Yii Via ComposerYii2 are having two apppliation in github.com/yiisoft/yii2. They are "Advanced application template", "Basic application template"
Install Advanced Application Template[caption id="attachment_1580" align="aligncenter" width="580"] Install yii2 application via composer[/caption] To install "advanced application template", use the following code
composer create-project yiisoft/yii2-app-advanced projAdvanced 2.0.0-beta
php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced /path/to/yii-application
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced your_project_name
Install Basic Application TemplateTo install "basic application template", use the following code
composer create-project yiisoft/yii2-app-basic projBasic 2.0.0-beta
composer create-project --prefer-dist yiisoft/yii2-app-basic basic_project_name
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic_project_name
Folder Structure Of Advanced Application TemplateAfter installed 'advanced application template', you will get the application like below folder structure. [caption id="attachment_1579" align="aligncenter" width="643"] yii2 advanced application folder structure[/caption] Root directory contains a set of folder.
backend- backend web application.
common- files common to all applications.
console- console application.
environments- environment configs.
frontend- frontend web application.
.gitignorecontains a list of directories ignored by git version system. If you need something never get to your source code repository, add it there.
composer.json- Composer config described in detail below.
init- initialization script described in "Composer config described in detail below".
init.bat- same for Windows.
LICENSE.md- license info. Put your project license there. Especially when opensourcing.
README.md- basic info about installing template. Consider replacing it with information about your project and its installation.
requirements.php- Yii requirements checker.
yii- console application bootstrap.
yii.bat- same for Windows.
Installing from an Archive FileInstalling Yii from an archive file involves two steps:
- Download the archive file from yiiframework.com
- Unpack the downloaded file to a Web accessible folder.
Getting StartedAfter you install the application, you have to conduct the following steps to initialize the installed application. You only need to do these once for all. [caption id="attachment_1605" align="aligncenter" width="667"] Yii2 Installation Via Composer[/caption]
- Run command init to initialize the application with a specific environment.
- Create a new database and adjust the components['db'] configuration in common/config/main-local.php accordingly.
- Apply migrations with console command yii migrate. This will create tables needed for the application to work.
Set document roots of your Web server: