码迷,mamicode.com
首页 > 其他好文 > 详细

laravel指令备忘

时间:2016-09-11 20:19:21      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

新建项目

cd “需要生成项目的根目录”

composer create-project laravel/laravel=4.2.* “项目名” --prefer-dist

 

部署项目

 php -S localhost:“端口号” -t public

 

加载自定义类文件夹

找到composer.json中定义的
    "autoload": {
        "classmap": [
            "database"
            ,"app/library/class"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
执行 composer dumpautoload  

 

日志扩展

class SPLogger
{
    // 所有的LOG都要求在这里注册
    const LOG_ERROR     = ‘error‘;
    const LOG_INFO      = ‘info‘;
    const LOG_DEBUG     = ‘debug‘;
    const LOG_SQL       = ‘sql‘;

    private static $loggers = array();

    // 获取一个实例
    public static function getLogger($type = self::LOG_ERROR, $day = 30)
    {
        if (empty(self::$loggers[$type])) {
            self::$loggers[$type] = new Writer(new Logger($type));
//            self::$loggers[$type]->useDailyFiles(‘/usr/local/SpManaPlat‘.‘/logs/‘. $type .‘.log‘, $day);
            self::$loggers[$type]->useDailyFiles(storage_path().‘/logs/‘. $type .‘.log‘, $day);
        }

        $log = self::$loggers[$type];
        return $log;
    }
}
Class PublicAPI
{

    public static function log($log_string)
    {
//        $action = Route::current()->getActionName();
//        list($class, $method) = explode(‘@‘, $action);//字符串分割


        $log = [
            ‘message‘ => $log_string,       //消息
            ‘url‘ => Request::url(),        //当前地址
            ‘input‘ => Input::all(),        //输入参数
            ‘time‘ => date(‘Y-m-d H:i:s‘),  //时间
        ];

        SPLogger::getLogger(SPLogger::LOG_DEBUG)->debug($log);

    }
}

 

 

 

 

 

 

 

laravel指令备忘

标签:

原文地址:http://www.cnblogs.com/huangdahai/p/5862464.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!