How to install yii2.0 basic and advanced application using composer and archived files
Currently, there are two Yii 2.0 application templates available:
- Basic Application Template – a basic frontend application template.
- Advanced Application Template – consisting of a frontend, a backend, console resources, common (shared code), and support for environments.
- Make sure you are using php version > php 5.4, if not upgrade it.
- To enable or recompile php with openssl, Find line
C:\wamp\bin\php\php.version\php.iniand uncomment it by removing the semicolon (
;) from the beginning of the line.
Note: WAMP uses different php.ini files in the CLI and for Apache. when you enable php openssl through the WAMP UI, you enable it for Apache, not for the CLI. You need to modify
C:\wamp\bin\php\php.version\php.ini to enable it for the CLI otherwise, it shows error “openssl extension is missing” while installing composer.
Download and run https://getcomposer.org/Composer-Setup.exe
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
Installing Yii2.0 Basic Application Template via composer
To install basic application template, make sure your command prompt directory pointing to web accessible folder c:/wamp/www and type the following command in command prompt.
c:\wamp\www> composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic yii2-basic
c:\> composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic c:/wamp/www/yii2-basic
Folder Structure Of Basic Application Template
After installation of yii2.0 basic application template, you will get the folder structure like this.
Access your basic application template via
Installing Yii2.0 Advanced Application Template via composer
To create advanced application template, make sure your command prompt directory pointing to web accessible folder
c:/wamp/www and type the following command in command prompt.
c:\>composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced c:/wamp/www/yii2advanced
c:\wamp\www> composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced yii2advanced
Folder Structure Of Advanced Application Template
After installation of yii2.0 advanced application template, you will get the folder structure like this.
Installing Yii2.0 from an Archive File
- Download the archive file from yiiframework.com
- Unpack the downloaded file to a Web accessible folder.
- After installation of application, you have to follow these steps to initialize the installed application. You only need to do these once for all.
type the following code in your command prompt to inititalise
- Create a new database and adjust the
- Apply migrations with console command
c:\wamp\www\yii2advanced> yii migrate
- Set document roots of your Web server:
/path/to/yii-application/frontend/web/[ In my case
/path/to/yii-application/backend/web/[ In my case
Yii2.0 Advanced Application Frontend Template
Yii2.0 Advanced Application Backend Template