mikehaertl / yii2-base-app
A Yii 2 Application Template For Purists
Installs: 62
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 2
Open Issues: 0
Type:project
pkg:composer/mikehaertl/yii2-base-app
Requires
- php: >=5.4.0
- yiisoft/yii2: 2.0.*
- yiisoft/yii2-bootstrap: 2.0.*
- yiisoft/yii2-swiftmailer: 2.0.*
Requires (Dev)
This package is auto-updated.
Last update: 2025-10-24 06:52:26 UTC
README
Features
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_DEBUGandYII_ENVto configuration files - SiteController with login, logout, signup and password forget actions
Configuration
All configuration lives in 4 (or 5) files in the config/ directory.
web.phpconfiguration of the web applocal.phplocal overrides to the web config. This file is not committed.console.phpconfiguration of the console. Here you can reuse parts of the mergedweb.phpandlocal.phpconfiguration. See the example file for how this works.params.phpapplication parameters for both web and console applicationconsole-local.phpan optional file with local overrides to the console configuration. This file is not committed.
Workflow
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:
- Install the template with
composer create-project --prefer-dist --stability=dev mikehaertl/yii2-base-app . - Add optional dependencies to
composer.jsonand runcomposer update - Add local configuration to
config/local.php(DB, etc.) - Check
config/params.php,config/web.phpandconfig/console.phpand add project wide configuration - Check
migrations/m140328_144900_initto suit your user table schema. - Check the models in
models/and add/remove attributes. - 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-commandstep a unique cookie validation key is automatically generated and added toconfig/local.phpfor you.
Note 2:
composer updateabove may fail with an error about github rate limit exceeded. Have a look here for how to resolve this issue.
Development
To keep this template updated with the latest package version, we should run composer update
from time to time and then commit composer.lock.