您知道,带有adminlte的yii2存在于此git。
但如果我使用作曲家使用它,它不会给我一个教育。 你知道,我想逐步学习。
所以我试过这样:
现在,我像这样编辑assets / AppAsset:
class AppAsset extends AssetBundle {
public $basePath = '@webroot';
public $baseUrl = '@web';
public $sourcePath = '@bower/'adminLTE';
public $css = [
'adminLTE/dist/css/AdminLTE.min.css',
'css/site.css',
];
public $js = [
'adminLTE/dist/js/app.js'
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yii\bootstrap\BootstrapPluginAsset',
];
}
但是,下面的css和js都是404?
任何帮助它如此赞赏
答案 0 :(得分:1)
如果您想手动添加AdminLTE,则无需将其放在bower
文件夹中。
将其放在/web
文件夹中(如果是高级模板/frontend/web
或/backend/web
)。
您已为此文件夹设置了AppAsset,但您必须删除$sourcePath
,因为设置$basePath
时会覆盖$baseUrl
。
答案 1 :(得分:1)
不要在供应商中添加主题以手动安装主题。按照下面提到的步骤。
第1步:下载您的管理员并在根目录中创建名为theme的目录
ex. your_project/basic/themes ( i.e outside the web directory)
第2步:将您的adminlte主题文件夹粘贴到新创建的主题目录
中第3步:现在您需要创建资产来注册adminlte主题所需的所有css和js
转到 your_project / basic / assets 目录并创建一个新文件,例如 AdminLTEAsset.php
namespace app\assets;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class AdminLTEAsset extends AssetBundle {
public $sourcePath = '@app/themes/adminlte/';
public $css = [
'dist/css/AdminLTE.css',
'font-awesome-4.5.0/css/font-awesome.min.css',
'ionicons/2.0.1/css/ionicons.min.css',
'dist/css/skins/_all-skins.min.css',
];
public $js = [
'dist/js/app.js',
'plugins/slimScroll/jquery.slimscroll.min.js',
'plugins/fastclick/fastclick.min.js',
'dist/js/demo.js',
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yii\bootstrap\BootstrapPluginAsset',
];
}
第4步:现在转到 themes / adminlte / layouts / main.php 并注册新创建的 AdminLTEAsset 。如下。
$assets = app\assets\AdminLTEAsset::register($this);
$basUrl = $assets->baseUrl;
第5步:在 /config/web.php 文件中添加以下路径图
'components'=>[
'view' => [
'theme' => [
'pathMap' => ['@app/views' => '@app/themes/adminlte'],
'baseUrl' => '@web/../themes/adminlte',
],
],
]
答案 2 :(得分:0)
嵌入管理主题i yii2 basic
1)使用composer
创建yii项目sudo du cd / var / www / html 作曲家创作项目yiisoft / yii2-app-basic basic 2.0.4
2)现在创建它可访问
chmod 777 -R项目名称
3)使用
下载admin lte主题git clone https://github.com/bmsrox/baseapp-yii2basic-adminlte.git
4)现在更新作曲家
作曲家更新
如果令牌错误,则在git中创建帐户,并通过单击genarate new token
在设置选项卡中创建令牌复制并提供给作曲家
5)更新config
中的web.php文件<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'layout'=>'column2',
'layoutPath'=>'@app/themes/adminLTE/layouts',
'components' => [
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
''=>'site/index',
'<action:(index|login|logout)>'=>'site/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>'
],
],
'view' => [
'theme' => [
'pathMap' => ['@app/views' => '@app/themes/adminLTE'],
'baseUrl' => '@web/../themes/adminLTE',
],
],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'n0VkMX1RmIa_ovJmwR3Gn_hdZyQ7SyKe',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => require(__DIR__ . '/db.php'),
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
//$config['modules']['gii'] = 'yii\gii\Module';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'generators' => [ //here
'crud' => [ // generator name
'class' => 'yii\gii\generators\crud\Generator', // generator class
'templates' => [ //setting for out templates
'custom' => '@vendor/bmsrox/yii-adminlte-crud-template', // template name => path to template
]
]
],
];
}
return $config;
6)更新SiteController。控制器文件夹中的Php
将actionLogout替换为以下代码
public function actionLogout()
{
Yii::$app->user->logout();
return $this->redirect(Yii::$app->user->loginUrl);
}
public function beforeAction($action)
{
if (parent::beforeAction($action)) {
// change layout for error action
if ($action->id=='login')
$this->layout = 'login';
return true;
} else {
return false;
}
}
7)如果错误配置错误则
更新apche2
使用命令
a2enmod重写
并使用
来限制apacheservice apache2 restart
完成...........
祝你好运