Yii2 boilerplate app

A selection of Yii2 framework extensions and tools configured and ready for building web applications



Pre-configured administration pages - users/roles/permissions/settings/posts/files

ORM (Object Relational Mapping) tools for working with relational databases and search indexes

RESTful API tools for exposing resources to end users with authentication and authorization

Pre-configured Angular v4 boilerplate application


Get started with Yii2 Angular v4



Administration pages:

Why Yii2?


Configurations are widely used in Yii2 for creating new objects or initializing existing objects.

The dependency injection (DI) container knows how to instantiate and configure objects and all their dependent objects.

  • // create an object using configuration array
  • $object = Yii::createObject([
  • 'class' => 'yii\db\Connection',
  • 'dsn' => 'mysql:host=127.0.0.1;dbname=demo',
  • 'username' => 'root',
  • 'password' => '',
  • 'charset' => 'utf8',
  • ]);


Yii2s DAO (Database Access Objects) and ORM (Object Relational Mapping) provide object-oriented APIs for accessing relational databases and search indexes.

  • // Query database
  • $rows = (new yii\db\Query())
  • ->select(['id', 'email'])
  • ->from('user')
  • ->where(['last_name' => 'Smith'])
  • ->limit(10)
  • ->all();


Yii2 provides RESTful API tools for exposing resources to end users with authentication (JWT) and authorization (roles/permissions) access control

  • // Map database model to API endpoint
  • use yii\rest\ActiveController;
  • class UserController extends ActiveController
  • {
  • public $modelClass = 'app\models\User';
  • public function behaviors()
  • {
  • $behaviors = parent::behaviors();
  • $behaviors['access'] = [
  • 'class' => 'yii\filters\AccessControl',
  • 'rules' => [
  • [
  • 'allow' => true,
  • 'actions' => ['options'],
  • 'roles' => ['?']
  • ],
  • [
  • 'allow' => true,
  • 'actions' => ['index', 'view'],
  • 'roles' => ['@']
  • ],
  • [
  • 'allow' => true,
  • 'actions' => ['update', 'create', 'delete'],
  • 'roles' => ['admin']
  • ]
  • ]
  • ];
  • return $behaviors;
  • }
  • }