An alternative Yii2 application template for purists


Written in PHP by 1 contributor


Need Support?

we offer maintenance, support and development services for all our open source projects.

Contact Us

Yii 2 Base App for Purists


The main tenet of this template is: Keep it simple! The idea was to only include the absolutely necessary features - and optimize some of the configuration issues of the original Yii2 base template.

  • Very flat configuration file structure
  • Provide local configuration files that won't get committed
  • Move YII_DEBUG and YII_ENV to configuration files
  • SiteController with login, logout, signup and password forget actions


All configuration lives in 4 (or 5) files in the config/ directory.

  • web.php configuration of the web app
  • local.php local overrides to the web config. This file is not committed.
  • console.php configuration of the console. Here you can reuse parts of the merged web.php and local.php configuration. See the example file for how this works.
  • params.php application parameters for both web and console application
  • console-local.php an optional file with local overrides to the console configuration. This file is not committed.


Before you can create new applications on a host, you first have to install the composer asset plugin:

composer global require "fxp/composer-asset-plugin:1.0.0-beta2"

To create a new application you will usually follow this workflow:

  1. Install the template with composer create-project --prefer-dist --stability=dev mikehaertl/yii2-base-app .
  2. Add optional dependencies to composer.json and run composer update
  3. Add local configuration to config/local.php (DB, etc.)
  4. Check config/params.php, config/web.php and config/console.php and add project wide configuration
  5. Check migrations/m140328_144900_init to suit your user table schema.
  6. Check the models in models/ and add/remove attributes.
  7. Run migrations with yii migrate

This should get you started. Your app should now run in a base version and is ready to be committed to your project repository.

Note: After the composer create-command step a unique cookie validation key is automatically generated and added to config/local.php for you.

Note 2: composer update above may fail with an error about github rate limit exceeded. Have a look here for how to resolve this issue.


To keep this template updated with the latest package version, we should run composer update from time to time and then commit composer.lock.

43 other PHP projects

phpwkhtmltopdfPHP 716

A slim PHP wrapper around wkhtmltopdf with an easy to use and clean OOP interface

php-pdftkPHP 213

A PDF conversion and form utility based on pdftk

yii2-localeurlsPHP 189

Automatic locale/language management for URLs

YiiRedisPHP 131

A set of wrappers for different data types in redis

yiipasswordPHP 81

Password strategies for Yii

yii2-dockerizedPHP 64

A template for docker based Yii 2 applications

YiiSolrPHP 50

A wrapper for the pecl solr library that provides common Yii constructs, such as models, data providers etc

php-shellcommandPHP 48

A simple object oriented interface to execute shell commands in PHP

Yii-Docs-GeneratorPHP 47

Generates HTML documentation for Yii applications

YiiGitPHP 36

A git wrapper for Yii, allows access to all git commands programatically

YiiElasticSearchPHP 32

Elastic Search client for Yii

YiiCurlPHP 30

A curl library for Yii

YiiStateMachinePHP 28

A state machine behavior for Yii

yii2-streamlogPHP 19

A Yii 2 log target for streams in URL format

oauth2yiiPHP 18

An OAuth2 client / server extension for the Yii framework

restyiiPHP 16

A RESTful extension for Yii.

packagecompressorPHP 16

A Javascript/CSS compressor based on Yii's package system

localeurlsPHP 12

Automatic locale/language management for URLs

php-excel-readerPHP 12

It reads the binary format of XLS files directly and can return values and formats from any cell. This project is the fork of http://code.google.com/p/php-excel-reader/ that, apparently, is no longer maintained.

pdfablePHP 10

A Yii extension to create PDFs with PHPWkHtmlToPdf/wkhtmltopdf

yii-api-vimPHP 8

Yii API manual plugin for VIM

yii2-excel-messagePHP 7

Translate messages via Excel files

xcrudcontrollerPHP 7

A base class to quickly build customized CRUD interfaces.

yii2-bs3activeformPHP 7

A Bootstrap 3 enhanced ActiveForm for Yii 2

php-tmpfilePHP 6

A convenience class for temporary files

handlebarsphpPHP 6

Transpiles handlebars templates into native PHP templates

Yii-Package-ManagerPHP 6

A package manager for Yii

php-orientdbPHP 5

A fast PHP driver for the OrientDB binary protocol.

yii2-apidoc-vimPHP 5

Yii2 apidoc as Vim helpfiles

translatablePHP 4

Transparent attribute translation for ActiveRecords

YiiUsersPHP 4

User management for Yii

flushablePHP 3

Yii dependency that allows to flush records from the cache

Yii-Resource-ManagerPHP 3

Helpers to allow Yii to interact with resources (files) of different types

AccessRestrictablePHP 2

A Yii ActiveRecordBehavior that automatically applies conditions for access restriction to every query.

bs3activeformPHP 2

A lightweight utility to render Bootstrap 3 forms in Yii

YiiEmailerPHP 2

Emailing functions for Yii

hybridauthmanagerPHP 1

An AuthManager for Yii that stores the hierarchy in a flat PHP file and the assignments in DB

defaultpersisterPHP 1

Yii extension to save and restore model values in user session.

YiiYaaPHP 1

YAA is an additional abstraction layer for Yii that aggregates a number of child models into a clean single model that is easy to cache

YiiLinkablePHP 1

A simple extension for Yii allowing easy and consistent access to model URLs and appropriate anchor text.


Yii extension to create URLs that allow to return to a page by storing its GET Parameters on a stack.


Work with PHP files in Active Record way


simple useless twitter client