Created
January 10, 2016 16:43
-
-
Save erycamel/9a1a5ca7288f2d78a81b to your computer and use it in GitHub Desktop.
YII2 Basic Template Admin LTE v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
]; | |
} | |
----------------------------------- |
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
"pheme/yii2-settings": "*"
yii migrate/up --migrationPath=@vendor/pheme/yii2-settings/migrations
https://thecodeninja.net/2014/12/i18n-with-yii-2-advanced-template/