A Yii 2 Base Project Template


A Yii 2 Base Project Template

Latest Stable Version Total Downloads License


  • Yii framework as the PHP MVC framework.

  • Security - It sets some headers that projects applications against click-jacking and XSS.

  • Assets version - This fixes issue with updates to js and css files and cached browser files.

  • New Relic - Ensures that the proper routes show up in the new relic monitoring dashboard.

  • Continuous Integration - Sample ant build.xml file that can be easily modified.


The minimum requirement by this project template that your Web server supports PHP 8.0.

Install via Composer

If you do not have Composer, you may install it by following the instructions at

You can then install this project template using the following command:

composer global require "fxp/composer-asset-plugin:~1.4"
composer create-project --prefer-dist cottacush/yii2-base-project new_project

Virtual Host Setup

Windows Link 1 Link 2

Mac Link 1 Link 2

Debian Linux Link 1 Link 2

Sample Virtual Host Config for Apache

<VirtualHost *:80>
    DocumentRoot "<WebServer Root Dir>/yii2-base-project/app/web"
    <Directory <WebServer Root Dir>/yii2-base-project/app/web>
       AllowOverride all
       Options -MultiViews
      Require all granted



Run build


Environment Variables

Make a copy of .env.sample to .env in the env directory.


This project is dockerized using the LEMP stack. The stack consists of:

  • PHP 8
  • nginx

Inspired by yii2-dockerized


Mac Windows Ubuntu

Running Containers

  • Ensure docker is running
  • Change directory to project directory
  • Run the command docker-compose up
  • To rebuild the containers after updates to docker config files, run docker-compose up --build

Entering Container CLI

  • Run the command docker ps
  • Check the Container ID for container with image ending with "_web"
  • Run the command docker exec -it [container_id] bash

Change log

Please see CHANGELOG for more information what has changed recently.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.