How to install yii2.0 basic and advanced application using composer and archived files

Posted by in Yii 2

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.

Before Installation:

  • Make sure you are using php version > php 5.4, if not upgrade it.
  • To enable or recompile php with openssl, Find line ;extension=php_openssl.dll in C:\wamp\bin\php\php.version\php.ini and 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.

Installing Composer

Download and run https://getcomposer.org/Composer-Setup.exe
OR
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
composer

yii2 Composer Installation

yii2 Composer Installation

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
OR
c:\> composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic c:/wamp/www/yii2-basic

Create Yii2 Basic Template using Composer

Create Yii2 Basic Application Template using Composer

Folder Structure Of Basic Application Template

After installation of yii2.0 basic application template, you will get the folder structure like this.

Folder Structure of Yii2 Basic Template

Folder Structure of Yii2 Basic Application Template

Access your basic application template via http://localhost/yii2-basic/web

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
OR
c:\wamp\www> composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced yii2advanced

Create Yii2 Advanced Template using Composer

Create Yii2 Advanced Template using Composer

Folder Structure Of Advanced Application Template

After installation of yii2.0 advanced application template, you will get the folder structure like this.

Folder Structure of Yii2 Advanced Application Template

Folder Structure of Yii2 Advanced Application Template

Installing Yii2.0 from an Archive File

  1. Download the archive file from yiiframework.com
  2. Unpack the downloaded file to a Web accessible folder.

Getting Started

  1. 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
    php c:/wamp/www/yii2advanced/init
    Yii2 Advanced Application Initialision

    Yii2 Advanced Application Initialision

  2. Create a new database and adjust the components.db configuration in C:/wamp/www/yii2advanced/common/config/main-local.php accordingly.
  3. Apply migrations with console command c:\wamp\www\yii2advanced> yii migrate
  4. Yii2 Migration

    Yii2 Migration

  5. Set document roots of your Web server:
    for frontend /path/to/yii-application/frontend/web/ [ In my case http://localhost/yii2advanced/frontend/web/index.php"
    for backend /path/to/yii-application/backend/web/ [ In my case http://localhost/yii2advanced/backend/web/]

Yii2.0 Advanced Application Frontend Template

Yii2 Advanced Application Frontend

Yii2 Advanced Application Frontend

Yii2.0 Advanced Application Backend Template

Yii2.0 Advanced Application Backend Template

Yii2.0 Advanced Application Backend Template

Share your comments

comments