Yii 2.0 Setup

Composer setup

Install php5-json as it is required for composer.

As root:

cd /tmp
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin
ln -s /usr/bin/composer.phar /usr/bin/composer

Directory Setup

Create the following directories assuming /var/www is the default webroot directory. p1 directory is the base install or Project 1 install in this case.

mkdir -p /var/www/yii2/p1
chown -R www-data:www-data /var/www/yii2/

Download Yii 2.0 Advanced Template

cd /var/www/yii2
svn checkout https://github.com/yiisoft/yii2-app-advanced/trunk/ p1

Install Dependencies Using Composer

cd /var/www/yii2/p1
composer install

Output

Installing dependencies (including require-dev)
  - Installing ezyang/htmlpurifier (v4.6.0)
    Loading from cache

  - Installing swiftmailer/swiftmailer (dev-master 37d5164)
    Cloning 37d5164b15d409753b4daa32b5b8d5ac7e4142c0

  - Installing phpspec/php-diff (dev-master 30e103d)
    Cloning 30e103d19519fe678ae64a60d77884ef3d71b28a

  - Installing yiisoft/jquery (2.1.0)
    Loading from cache

  - Installing yiisoft/yii2-composer (dev-master ced9e6a)
    Cloning ced9e6a1680b2e240f12c04c96443fd8ad65c515

  - Installing michelf/php-markdown (1.3)
    Loading from cache

  - Installing twbs/bootstrap (dev-master 00b3b8b)
    Cloning 00b3b8b0b8d5515b6eb1ea7064f6d88175306ed9

  - Installing yiisoft/yii2 (dev-master a33525b)
    Cloning a33525b0d5156d8422a2a737007e252aa0d77adc

  - Installing yiisoft/yii2-swiftmailer (dev-master 21062fb)
    Cloning 21062fb10ca6a89ada2448c08e13dd4c60603532

  - Installing yiisoft/yii2-bootstrap (dev-master 6cd480e)
    Cloning 6cd480ee4ab98831e931145b37fc0d6aea15b0c8

  - Installing yiisoft/yii2-debug (dev-master 7cfb77f)
    Cloning 7cfb77f479ffc254770460ac21db2d7d5e0fb35f

  - Installing yiisoft/yii2-gii (dev-master 5a5523f)
    Cloning 5a5523fadd9c080384cc91881dbf3cc4465f2acc

Writing lock file
Generating autoload files

Initialize Yii App

cd /var/www/yii2/p1
./init

Output:

Yii Application Initialization Tool v1.0

Which environment do you want the application to be initialized in?

  [0] Development
  [1] Production

  Your choice [0-1, or "q" to quit] 0

  Initialize the application under 'Development' environment? [yes|no] yes

  Start initialization ...

   generate frontend/web/index.php
   generate frontend/config/params-local.php
   generate frontend/config/main-local.php
   generate common/config/params-local.php
   generate common/config/main-local.php
   generate backend/web/index.php
   generate backend/config/params-local.php
   generate backend/config/main-local.php
   generate console/config/params-local.php
   generate console/config/main-local.php
   generate yii
      chmod 0755 yii

  ... initialization completed.

Post Install

Reset permissions

chown -R www-data:www-data /var/www/yii2/p1/

QR Code
QR Code tech:yii2:setup (generated for current page)