Skip to content

Instantly share code, notes, and snippets.

@erycamel
Created January 10, 2016 16:43
Show Gist options
  • Save erycamel/9a1a5ca7288f2d78a81b to your computer and use it in GitHub Desktop.
Save erycamel/9a1a5ca7288f2d78a81b to your computer and use it in GitHub Desktop.
YII2 Basic Template Admin LTE v2
Step 1 – Initialize your project - Create Yii2 Basic
php composer.phar global require "fxp/composer-asset-plugin:~1.1.1"
php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
Step 2 – Install FontAwesome - composer.json
"FortAwesome/Font-Awesome": "*",
Step 3 – Create your FontAwesome asset bundle
To register the files, we are going to create an asset bundle named FontAwesomeAsset.php
and place it on frontend(backend)/assets with the following contents:
------------------------------
namespace frontend\assets;
use yii\web\AssetBundle;
class FontAwesomeAsset extends AssetBundle
{
// The files are not web directory accessible, therefore we need
// to specify the sourcePath property. Notice the @vendor alias used.
public $sourcePath = '@vendor/fortawesome/font-awesome';
public $css = [
'css/font-awesome.css',
];
}
-----------------------------------
Registered as part of the main application asset bundle AppAsset:
-----------------------------------
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
// here we add our FontAwesomeAsset bundle class
'frontend\assets\FontAwesomeAsset'
];
}
-----------------------------------
@erycamel
Copy link
Author

"pheme/yii2-settings": "*"

yii migrate/up --migrationPath=@vendor/pheme/yii2-settings/migrations

https://thecodeninja.net/2014/12/i18n-with-yii-2-advanced-template/

@erycamel
Copy link
Author

@erycamel
Copy link
Author

Yii2 require all Controller and Action to login

'as beforeRequest' => [
'class' => 'yii\filters\AccessControl',
'rules' => [
[
'allow' => true,
'actions' => ['login'],
],
[
'allow' => true,
'roles' => ['@'],
],
],
'denyCallback' => function () {
return Yii::$app->response->redirect(['site/login']);
},
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment