yii2 合并js css的插件。

https://github.com/skeeks-semenov/yii2-assets-auto-compress
今天安装了一下这个插件,用来合并js,css。
下面是我安装的步骤:

composer  require --prefer-dist skeeks/yii2-assets-auto-compress "*"
Running composer as root/super user is highly discouraged as packages, plugins and scripts cannot always be trusted
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing mrclay/minify (2.3.0)                       
    Downloading: 100%         

  - Installing natxet/cssmin (v3.0.4)
    Downloading: 100%         

  - Installing tedivm/jshrink (v1.1.0)
    Downloading: 100%         

  - Installing skeeks/yii2-assets-auto-compress (1.1.1)
    Downloading: 100%         

mrclay/minify suggests installing tubalmartin/cssmin (Support minify with CSSMin (YUI PHP port))
Writing lock file
Generating autoload files
[root@iZ942k2d5ezZ fecshop]# 

安装完成后,添加配置:

[
    'bootstrap'    => ['assetsAutoCompress'],
    'components'    =>
    [
    //....
        'assetsAutoCompress' =>
        [
            'class'             => '\skeeks\yii2\assetsAuto\AssetsAutoCompressComponent',
            'enabled'           => true,
            'jsCompress'        => true,
            'cssFileCompile'    => true,
            'jsFileCompile'     => true,
        ],
    //....
    ]
]

添加完成后,去我的后台,发现了js都给合并起来放到了页面的底部。

css合并放到了页面的顶部:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="csrf-param" content="_csrf">
    <meta name="csrf-token" content="WnhJLnc3NFoqSAceInFwb2g6IRhBBBkwLUgaeRpjfCILKg5HDVZGIA==">
    <title></title>
    <link href="/assets/css-compress/a4b0c42ec77e84de019e80dabfbbdd26.css?v=1466129605" rel="stylesheet">
</head>

js 放到了页面的底部:

<script src="/assets/js-compress/6e9da28e384e6efd0451dfbc263c3fdd.js?v=1466129605"></script>
<script type="text/javascript">jQuery(window).load(function () {
 $(document).ready(function(){$("#login-captcha-image").click();});
});</script></body>
</html>

不过这种合并js和css的方法,还是会存在一定的问题,就和magento的css和js的合并,有一些插件合并起来还是会报错,我的后台用的是dwz,合并js后,会存在问题,尤其是dwz需要加载一个.xml文件,开启合并后,整体不能用了。

不过对于前台,如果不用一些乱起八糟的js库包,应该问题不大。

总体来说这个js和css合并不是万能,但是还是能解决一部分问题,譬如线上的电商网站等。

yii2 cron job 插件使用

1.当我们的系统比较庞大,有很多脚本的时候,如果都写到crontab中会比较大,而且在程序方面不是很友好,现在介绍的是在程序中实现cron

插件的地址为:https://github.com/DenisOgr/yii2-cronjobs

安装:

composer  --prefer-dist denisogr/yii2-cronjobs "dev-master"

2配置:

在console/config/bootstrap.php中加入配置:设置别名

<?php
Yii::setAlias('@runnerScript', dirname(dirname(dirname(__FILE__))) .'/yii');

在console/config/main.php中加入配置:设置cron的controller

'controllerMap' => [
       'cron' => [
           'class' => 'denisog\cronjobs\CronController'
       ],
   ],

加完配置后的main.php文件如下:

<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-console',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'console\controllers',
    'components' => [
        //'log' => [
        //    'targets' => [
        //        [
        //            'class' => 'yii\log\FileTarget',
        //            'levels' => ['error', 'warning'],
        //        ],
        //    ],
       // ],
  
  'errorHandler' => [
//           'maxSourceLines' => 30,

        ],
    ],

'controllerMap' => [
       'cron' => [
           'class' => 'denisog\cronjobs\CronController'
       ],
   ],
    'params' => $params,
];

3.配置log,这个是为了输出cron整体的log

\common\config\main.php组件中加入log的配置:也即是配置log categories:cron_controller_logs

'log' =>[
      # 追踪级别
      # 消息跟踪级别
      # 在开发的时候,通常希望看到每个日志消息来自哪里。这个是能够被实现的,通过配置 log 组件的 yii\log\Dispatcher::traceLevel 属性, 就像下面这样:
      'traceLevel' => YII_DEBUG ? 3 : 0,
      
      # 通过 yii\log\Logger 对象,日志消息被保存在一个数组里。为了这个数组的内存消耗, 当数组积累了一定数量的日志消息,日志对象每次都将刷新被记录的消息到 log targets 中。 你可以通过配置 log 组件的 yii\log\Dispatcher::flushInterval 属性来自定义数量
      'flushInterval' => 1,
      
            'targets' => [
                'file1' =>[
          //'levels' => ['warning'],

          'categories' => ['cron_controller_logs'],
                    'class' => 'yii\log\FileTarget',
          
          # 当 yii\log\Logger 对象刷新日志消息到 log targets 的时候,它们并 不能立即获取导出的消息。相反,消息导出仅仅在一个日志目标累积了一定数量的过滤消息的时候才会发生。你可以通过配置 个别的 log targets 的 yii\log\Target::exportInterval 属性来 自定义这个数量,就像下面这样:
                    'exportInterval' => 1,
          # 输出文件
          'logFile' => '@app/runtime/logs/cron_controller_logs.log',
          
          # 你可以通过配置 yii\log\Target::prefix 的属性来自定义格式,这个属性是一个PHP可调用体返回的自定义消息前缀
          'prefix' => function ($message) {
            
            return $message;
          },
          # 除了消息前缀以外,日志目标也可以追加一些上下文信息到每组日志消息中。 默认情况下,这些全局的PHP变量的值被包含在:$_GET, $_POST, $_FILES, $_COOKIE,$_SESSION 和 $_SERVER 中。 你可以通过配置 yii\log\Target::logVars 属性适应这个行为,这个属性是你想要通过日志目标包含的全局变量名称。 举个例子,下面的日志目标配置指明了只有 $_SERVER 变量的值将被追加到日志消息中。
          # 你可以将 logVars 配置成一个空数组来完全禁止上下文信息包含。或者假如你想要实现你自己提供上下文信息的方式, 你可以重写 yii\log\Target::getContextMessage() 方法。
           'logVars' => [],
                ],
        
            ],
        ],

创建log文件,设置写权限  :

touch console/runtime/logs/cron_controller_logs.log
chmod 777 console/runtime/logs/cron_controller_logs.log

4.我们就要开始添加我们的cron任务了

在console/config/params.php中加入配置:

'cronJobs' =>[
        'test/example1' => [
            'cron'      => '* * * * *', 
      'cron-stdout'=> '/tmp/ExampleCommand.log',
      'cron-stderr'=> '/tmp/ExampleCommandError.log',			
        ],
    'test/example2' => [
            'cron'      => '10 * * * *',            
        ],

    ],

更详细的规则参看:

https://github.com/Yiivgeny/Yii-PHPDocCrontab/blob/master/examples/ExampleRuCommand.php

 

也就是加入了两个cron任务,一个是test/example1 这个任务是每分钟执行一次,这个任务的输出文件为cron-stdout对应的log文件,错误输出文件为cron-stderr对应的log文件。  另外一个任务是  test/example2

下面我们需要创建log文件:

touch  /tmp/ExampleCommand.log
touch /tmp/ExampleCommandError.log
chmod 777  /tmp/ExampleCommand.log
chmod 777  /tmp/ExampleCommandError.log

然后创建controller:

<?php
namespace console\controllers;
use Yii;
use yii\console\Controller;

class TestController extends Controller
{

   public function actionExample11(){
                echo 1;exit;

        }



}

然后执行:

./yii cron/run
tail -f /tmp/ExampleCommandError.log

可以看到错误输出

Error: Unknown command "test/example1".

因为上面我们的controller的action是actionExample11  ,两个1,去掉一个,在执行

vim /tmp/ExampleCommand.log

 

可以看到文件内容如下:

1

由于这个插件默认是覆盖写,所以需要修改一下:

170行附近的代码:

$command =
           $this->interpreterPath.' '.
           $command.
           $concat . escapeshellarg($stdout).
           ' 2>'.(($stdout === $stderr)?'&1':escapeshellarg($stderr));
       if ($this->isWindowsOS()){

改成:

$command =
           $this->interpreterPath.' '.
           $command.
           $concat . escapeshellarg($stdout).
           ' 2>>'.(($stdout === $stderr)?'&1':escapeshellarg($stderr));
       if ($this->isWindowsOS()){

30行左右的代码:

public $updateLogFile = false;

改为:

public $updateLogFile = true;

 

这就就可以覆盖写了,修改后的CronController.php文件内容如下:

<?php
/**
 * User: Denis Porplenko <denis.porplenko@gmail.com>
 * Date: 16.07.14
 * Time: 14:51
 */
namespace denisog\cronjobs;
use Yii;
use yii\console\Controller;
use yii\console\Exception;
class CronController extends Controller {
    const CATEGORY_LOGS = 'cron_controller_logs';
    /**
     * @var string PHPDoc tag prefix for using by PHPDocCrontab extension.
     */
    public $tagPrefix = 'cron';
    /**
     * @var string PHP interpriter path (if empty, path will be checked automaticly)
     */
    public $interpreterPath = null;
    /**
     * @var string path to writing logs
     */
    public $logsDir = null;
    /**
     * Update or rewrite log file
     * False - rewrite True - update(add to end logs)
     * @var bool
     */
    public $updateLogFile = true;
    /**
     * Placeholders:
     *     %L - logsDir path
     *     %C - name of command
     *     %A - name of action
     *     %P - pid of runner-script (current)
     *     %D(string formatted as arg of date() function) - formatted date
     * @var string mask log file name
     */
    public $logFileName = '%L/%C.%A.log';
    /**
     * @var string Bootstrap script path (if empty, current command runner will be used)
     */
    public $bootstrapScript = null;
    /**
     * @var string Timestamp used as current datetime
     * @see http://php.net/manual/en/function.strtotime.php
     */
    public $timestamp = 'now';
    /**
     * @var string the name of the default action. Defaults to 'run'.
     */
    public $defaultAction = 'run';
    /**
     * Initialize empty config parameters.
     */
    public function init() {
        parent::init();
        //Checking PHP interpriter path
        if ($this->interpreterPath === null){
            if ($this->isWindowsOS()){
                //Windows OS
                $this->interpreterPath = 'php.exe';
            }
            else{
                //nix based OS
                $this->interpreterPath = '/usr/bin/env php';
            }
        }
        //Checking logs directory
        if ($this->logsDir === null){
            $this->logsDir = Yii::$app->getRuntimePath();
        }
        //Checking bootstrap script
        if ($this->bootstrapScript === null){
            $this->bootstrapScript = Yii::getAlias('@runnerScript');
        }
    }
    /**
     * Provides the command description.
     * @return string the command description.
     */
    public function getHelp() {
        $commandUsage = Yii::getAlias('@runnerScript').' '.$this->getName();
        return <<<RAW
Usage: {$commandUsage} <action>
Actions:
    view <tags> - Show active tasks, specified by tags.
    run <options> <tags> - Run suitable tasks, specified by tags (default action).
    help - Show this help.
Tags:
    [tag1] [tag2] [...] [tagN] - List of tags
Options:
    [--tagPrefix=value]
    [--interpreterPath=value]
    [--logsDir=value]
    [--logFileName=value]
    [--bootstrapScript=value]
    [--timestamp=value]
RAW;
    }
    /**
     * Transform string datetime expressions to array sets
     *
     * @param array $parameters
     * @return array
     */
    protected function transformDatePieces(array $parameters){
        $dimensions = array(
            array(0,59), //Minutes
            array(0,23), //Hours
            array(1,31), //Days
            array(1,12), //Months
            array(0,6),  //Weekdays
        );
        foreach ($parameters AS $n => &$repeat) {
            list($repeat, $every) = explode('\\', $repeat, 2) + array(false, 1);
            if ($repeat === '*') $repeat = range($dimensions[$n][0], $dimensions[$n][1]);
            else {
                $repeatPiece = array();
                foreach (explode(',', $repeat) as $piece) {
                    $piece = explode('-', $piece, 2);
                    if (count($piece) === 2) $repeatPiece = array_merge($repeatPiece, range($piece[0], $piece[1]));
                    else                     $repeatPiece[] = $piece[0];
                }
                $repeat = $repeatPiece;
            }
            if ($every > 1) foreach ($repeat AS $key => $piece){
                if ($piece%$every !== 0) unset($repeat[$key]);
            }
        }
        return $parameters;
    }
    /**
     * Parsing and filtering PHPDoc comments.
     *
     * @param string $comment Raw PHPDoc comment
     * @return array List of valid tags
     */
    protected function parseDocComment($comment){
        if (empty($comment)) return array();
        //Forming pattern based on $this->tagPrefix
        $pattern = '#^\s*\*\s+@('.$this->tagPrefix.'(-(\w+))?)\s*(.*?)\s*$#im';
        //Miss tags:
        //cron, cron-tags, cron-args, cron-strout, cron-stderr
        if (preg_match_all($pattern, $comment, $matches, PREG_SET_ORDER)){
            foreach ($matches AS $match) $return[$match[3]?$match[3]:0] = $match[4];
            if (isset($return[0])){
                $return['_raw'] = preg_split('#\s+#', $return[0], 5);
                $return[0] = $this->transformDatePieces($return['_raw']);
                //Getting tag list. If empty, string "default" will be used.
                $return['tags'] = isset($return['tags'])?preg_split('#\W+#', $return['tags']):array('default');
                return $return;
            }
        }
    }
    /**
     * OS-independent background command execution .
     *
     * @param string $command
     * @param string $stdout path to file for writing stdout
     * @param string $stderr path to file for writing stderr
     */
    protected function runCommandBackground($command, $stdout, $stderr){
        $concat = ($this->updateLogFile) ? ' >>' : ' >';
        $command =
            $this->interpreterPath.' '.
            $command.
            $concat . escapeshellarg($stdout).
            ' 2>>'.(($stdout === $stderr)?'&1':escapeshellarg($stderr));
        if ($this->isWindowsOS()){
            //Windows OS
            pclose(popen('start /B "Yii run command" '.$command, 'r'));
        }
        else{
            //nix based OS
            system($command.' &');
        }
    }
    /**
     * Checking is windows family OS
     *
     * @return boolean return true if script running under windows OS
     */
    protected function isWindowsOS(){
        return strncmp(PHP_OS, 'WIN', 3) === 0;
    }
    /**
     * Running actions associated with {@link PHPDocCrontab} runner and matched with timestamp.
     *
     * @param array $args List of run-tags to running actions (if empty, only "default" run-tag will be runned).
     */
    public function actionRun($args = array()){
        $tags = &$args;
        $tags[] = 'default';
        //Getting timestamp will be used as current
        $time = strtotime($this->timestamp);
        if ($time === false) throw new CException('Bad timestamp format');
        $now = explode(' ', date('i G j n w', $time));
        $runned = 0;
        foreach ($this->prepareActions() as $task) {
            if (array_intersect($tags, $task['docs']['tags'])){
                foreach ($now AS $key => $piece){
                    //Checking current datetime on timestamp piece array.
                    if (!in_array($piece, $task['docs'][0][$key])) continue 2;
                }
                //Forming command to run
                $command = $this->bootstrapScript.' '.$task['command'].'/'.$task['action'];
                if (isset($task['docs']['args'])) $command .= ' '.escapeshellcmd($task['docs']['args']);
                //Setting default stdout & stderr
                if (isset($task['docs']['stdout'])) $stdout = $task['docs']['stdout'];
                else                                $stdout = $this->logFileName;
                $stdout = $this->formatFileName($stdout, $task);
                if(!is_writable($stdout)) {
                    $stdout = '/dev/null';
                }
                $stderr = isset($task['docs']['stderr'])?$this->formatFileName($task['docs']['stderr'], $task):$stdout;
                if(!is_writable($stderr)) {
                    $stdout = '/dev/null';
                }
                $this->runCommandBackground($command, $stdout, $stderr);
                Yii::info('Running task ['.(++$runned).']: '.$task['command'].' '.$task['action'], self::CATEGORY_LOGS);
            }
        }
        if ($runned > 0){
            Yii::info('Runned '.$runned.' task(s) at '.date('r', $time), self::CATEGORY_LOGS);
        } else {
            Yii::info('No task on '.date('r', $time), self::CATEGORY_LOGS);
        }
    }
    /**
     * Show actions associated with {@link PHPDocCrontab} runner.
     *
     * @param $args array List of run-tags for filtering action list (if empty, show all).
     */
    public function actionView($args = array()){
        $tags = &$args;
        foreach ($this->prepareActions() as $task) {
            if (!$tags || array_intersect($tags, $task['docs']['tags'])){
                //Forming to using with printf function
                $times = $task['docs']['_raw'];
                array_unshift($times, $task['command'].'.'.$task['action']);
                array_unshift($times, "Action %-40s on %6s %6s %6s %6s %6s %s\n");
                array_push($times, empty($task['docs']['tags'])?'':(' ('.implode(', ', $task['docs']['tags']).')'));
                call_user_func_array('printf', $times);
            }
        }
    }
    protected function formatFileName($pattern, $task){
        $pattern = str_replace(
            array('%L', '%C', '%A', '%P'),
            array($this->logsDir, $task['command'], $task['action'], getmypid()),
            $pattern
        );
        return preg_replace_callback('#%D\((.+)\)#U', create_function('$str', 'return date($str[1]);'), $pattern);
    }
    /**
     * Help command. Show command usage.
     */
    public function actionHelp(){
        echo $this->getHelp();
    }
    /**
     * Getting tasklist.
     *
     * @return array List of command actions associated with {@link PHPDocCrontab} runner.
     */
    protected function prepareActions()
    {
        $actions = array();
        try {
            $methods = Yii::$app->params['cronJobs'];
        }catch (yii\base\ErrorException $e) {
            throw new yii\base\ErrorException('Empty param cronJobs in params. ',8);
        }
        if (!empty($methods)) {
            foreach ($methods as $runCommand => $runSettings) {
                $runCommand = explode('/', $runCommand);
                if (count($runCommand) == 2) {
                    $actions[] = array(
                        'command' => $runCommand[0],
                        'action'  => $runCommand[1],
                        'docs'    => $this->parseDocComment($this->arrayToDocComment($runSettings))
                    );
                }
                if (count($runCommand) == 3) {
                    $actions[] = array(
                        'command' => $runCommand[0] . '/' . $runCommand[1],
                        'action'  => $runCommand[2],
                        'docs'    => $this->parseDocComment($this->arrayToDocComment($runSettings))
                    );
                }
                if (count($runCommand) == 4) {
                    $actions[] = array(
                        'command' => $runCommand[0] . '/' . $runCommand[1] .  '/' . $runCommand[2],
                        'action'  => $runCommand[3],
                        'docs'    => $this->parseDocComment($this->arrayToDocComment($runSettings))
                    );
                }
                if(empty($actions)) {
                    continue;
                }
            }
        }
        return $actions;
    }
    protected function arrayToDocComment(array $runSettings)
    {
        $result = "/**\n";
        foreach ($runSettings as $key => $setting) {
            $result .= '* @' . $key . ' ' . $setting . "\n";
        }
        $result .= "*/\n";
        return $result;
    }
}

然后我们需要设置cron ,让 ./yii cron/run 可以每分钟运行。

在console/config/params.php文件配置cron

每隔2分钟运行一次

'cron'      => '*\2 * * * *',

分:每1025,26,27,28,29,3040分钟

时:每天第2(偶数)小时

天:15至21和从23至27的数

月:一月至六月,偶数月

周:不管第几周

'cron' => '10,25-30,40 *\2 15-21,23-27 1-6\2 *',

 

 

Yii2 – 如何写一个插件 , 如何做一个扩展

1.在github申请账户,申请完成就可以创建项目了

2.创建一个composer.json文件:内容如下:

{  
  "name": "zqy234/terrytest",  
  "description": "Yii2 zqy234 terrytest",  
  "keywords": [  
    "yii2",  
    "terrytest"  
  ],  
  "homepage": "https://github.com/zqy234/terrytest",  
  "type": "yii2-extension",  
  "license": "MIT",  
  "support": {  
    "source": "https://github.com/zqy234/terrytest"  
  },  
  "authors": [  
    {  
      "name": "terry water",  
      "email": "zqy234@126.com"  
    }  
  ],  
  "minimum-stability": "stable",  
  "require": {  
    "php": ">=5.4.0",  
    "yiisoft/yii2": ">=2.0.6"  
     
  },  
  "autoload": {  
    "psr-4": {  
      "terry\\": ""  
    }  
  },  
  "config": {  
    "process-timeout": 1800  
  }  
}

我的扩展的地址为:https://github.com/zqy234/terrytest

上面的信息大致核对自己的地址填写,比较重要的为下面

2.1.require 这个是当前插件需要的库包

2.2.autoload:为在aotuload自动加载的信息,psr-4:所在部分加入自动加载的信息,当访问terry\开头的,都会到这个插件的路径下面找文件。

在插件安装的时候,上面psr-4的信息会安装到文件/vendor/composer/autoload_psr4.php 中,具体信息,可以到这个文件夹中查看详细。

3.搞完上面的,我们需要在包管理里面添加。

打开:https://packagist.org/packages/submit

把github的地址提交,提交成功后的界面:

4.到这里就提交成功了,您可以使用composer下载了:

[root@iZ942k2d5ezZ cc]# composer require  zqy234/terrytest:dev-master  
./composer.json has been updated  
Loading composer repositories with package information  
Updating dependencies (including require-dev)  
  - Installing zqy234/terrytest (dev-master c80914f)  
    Cloning c80914fc7dedc2f464f16fb0af5d3a843326bddb  
  
Writing lock file  
Generating autoload files

5.使用正式版本号(稳定版本号)

首先去github中:

然后再packagist中更新:

然后就可以更新了:

[root@iZ942k2d5ezZ cc]# composer require --prefer-dist zqy234/terrytest  
Using version ^1.0 for zqy234/terrytest  
./composer.json has been created  
Loading composer repositories with package information  
Updating dependencies (including require-dev)  
  - Installing yiisoft/yii2-composer (2.0.3)                 
    Loading from cache  
  
  - Installing bower-asset/jquery (2.1.4)  
    Loading from cache  
  
  - Installing bower-asset/yii2-pjax (v2.0.5)  
    Loading from cache  
  
  - Installing bower-asset/punycode (v1.3.2)  
    Loading from cache  
  
  - Installing bower-asset/jquery.inputmask (3.1.63)  
    Loading from cache  
  
  - Installing cebe/markdown (1.1.0)  
    Loading from cache  
  
  - Installing ezyang/htmlpurifier (v4.6.0)  
    Loading from cache  
  
  - Installing yiisoft/yii2 (2.0.6)  
    Loading from cache  
  
  - Installing zqy234/terrytest (1.0.0)  
    Downloading: 100%           
  
Writing lock file  
Generating autoload files  
[root@iZ942k2d5ezZ cc]#

这样就安装成功了。

6.版本号自动更新(github和packagist之间)

访问:https://packagist.org/profile/

获取api token

详细说明地址:https://packagist.org/about

填写的url的格式:https://packagist.org/api/bitbucket?username=USERNAME&apiToken=API_TOKEN

可以用:

curl -XPOST -H'content-type:application/json' 'https://packagist.org/api/update-package?username=USERNAME&apiToken=API_TOKEN' -d'{"repository":{"url":"PACKAGIST_PACKAGE_URL"}}'

来检测。

测试:

在github那边增加一个稳定版本号

然后再 https://packagist.org/packages/zqy234/terrytest#1.0.1

发现:1.0.1出来了。

基本的详细大致使用就这些

总之,可以快乐的,让别人下载自己的库包了

composer require --prefer-dist zqy234/terrytest

 

YII2 FEC 扩展

github地址为:https://github.com/fancyecommerce/yii2-fec

本插件为一些日常所用的函数类的封装

安装方法:

composer require --prefer-dist fancyecommerce/fec

安装完成后,可以在

/vendor/fancyecommerce/fec文件夹下面看到本插件的文件。

具体的插件信息:

一:基本功能封装部分:

CApi
CCache
CConfig
CCookie
CDate
CDB
CDir
CDoc
CEmail
CExcel
CFile
CFunc
CImage
CLog
CMessage
CModel
CModule
CProfile
CRequest
CSession
CTranslate
CUrl
CUser

 

具体的详细,可以在\fec\helpers里面查看具体的功能要点。这些都是一些帮助类,快速的实现某些功能。

Yii2 DWZ JUI 扩展 插件

本人写的一个YII2 DWZ整合的后台账户管理,菜单权限控制,日志管理,缓存管理的的admin UI.欢迎下载:

Yii2 Fancy Ecommerce ADMIN (FEC ADMIN)

DEMO: http://demo.fancyecommerce.com/

测试账户: admin admin123(密码)

下面是github部分的内容,欢迎下载!

github: https://github.com/fancyecommerce/yii2_fec_admin/


作者 :Terry

作者QQ : 2358269014

作者Email : 2358269014@qq.com


有任何建议或者需求欢迎来反馈 issues

欢迎点击右上方的 star 收藏

fork 参与开发,欢迎提交 Pull Requests,然后 Pull Request


1、安装

安装这个扩展的首选方式是通过 composer.

执行

composer require --prefer-dist fancyecommerce/fec_admin

或添加

"fancyecommerce/fec_admin": "~1.3.3"  
composer install

 

2、配置

配置:在原来的基础上添加如下代码:main.php

'modules'=>[  
        'fecadmin' => '\fecadmin\Module',  
    ],  
 'components' => [  
       'user' => [  
            'identityClass' => 'fecadmin\models\AdminUser',  
            'enableAutoLogin' => true,  
        ],  
        'urlManager' => [  
                'class' => 'yii\web\UrlManager',  
                'enablePrettyUrl' => true,  
                'showScriptName' => false,  
                'rules' => [  
                    '' => 'fecadmin/index/index',  
                    //'blog' => 'blog/index/index',  
  
                ],  
            ],  
        ],

param设置:config/param.php

<?php  
return [  
    'theme'             =>  'default',  
    'systemlog'         => [  
                    'enable' => true,  
                ],  
];