首页 > 代码库 > laravel指令备忘

laravel指令备忘

新建项目

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指令备忘