Laravel调试方法

作者: 分类: laravel 时间: 2015-12-06 评论: 暂无评论

这篇文章用于列举Laravel的调试方法

1.最常用的 dd(),var_dump();

2.debug插件。可以显示sql执行时间,语句。用来做Laravel优化也不错。插件Github地址https://github.com/itsgoingd/clockwork

3.Log::info(),Log::error() 打印的结果在storage文件夹里面。比如淘宝的异步通知,就可以用这个测试,很方便。

4.打印Laravel sql语句方法

$queries = DB::getQueryLog(); 
$last_query = end($queries);

或者

DB:listen(function($sql)){
    Log:info($sql->sql.'--'.$sql->time)
}

Laravel常见错误

作者: 分类: laravel 时间: 2015-12-06 评论: 暂无评论
1.Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

①没有这个路由或者控制器没有这个方法。
②路由中绑定了对象,根据路径的值去找对象,没有找到这个对象,也是报这个错

2.Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

当提交表单的方法是POST时候,得提交_token值,当然你也可以选择禁用token,或者只让某个路由post提交时,不用验证_token,比如APP与网站API的交互,淘宝的异步通知。

<input type="hidden" name='_token' value="{{csrf_token();}}">

3.You need to use the $fillable property in your Activation class when you use Mass Assignment.
你使用的插入sql语句需要给Model添加可批量插入字段白名单。

protected $fillable = ['id', 'token'];

4.Relationship method must return an object of type IlluminateDatabaseEloquentRelationsRelation
你可能调用了 $model->user这样的方法,找不到user这个对象或者属性报错。

Laravel 中文手册

作者: 分类: laravel 时间: 2015-12-05 评论: 暂无评论

Laravel4.0chm版,laravel离线网页版(4.0,4.1,5.0,5.1)

Composer安装

作者: 分类: laravel 时间: 2015-12-05 评论: 暂无评论

打开终端输入:

curl -sS https://getcomposer.org/installer | php

然后把composer.phar移动到目录/usr/local/bin/composer下(配置成全局命令)

mv composer.phar /usr/local/bin/composer

注意:这里的/user/local/php/php.ini(如果找不到,请使用<?php phpinfo();?>查看安装位置)要开启ssl模块。

#去分号,如下
extension=php_openssl.dll 

Linux环境git升级为最新版(绝对好用)

作者: 分类: git 时间: 2015-12-05 评论: 暂无评论

从github上下载的最新git包,然后安装。


yum install install autoconf automake libtool gcc zlib-devel perl-ExtUtils-MakeMaker package gettext-devel curl curl-devel
wget https://github.com/git/git/archive/v2.9.2.tar.gz
tar zxvf v2.9.2.tar.gz
cd git-2.9.2
make configure
./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
make all doc
make install install-doc install-html
sudo vim /etc/profile
# 在最后一行添加
export PATH=/usr/local/git/bin:$PATH
#保存后使其立即生效
source /etc/profile

[错误]

yum install git #v 1.7 

在linux系统下,git从网上下载code,但报错误,:fatal: Unable to find remote helper for 'https'

如果安装了git,应该会找到目录 /usr/libexec/git-core

将这个目录添加到 /root/.bash_profile 中

PATH=/usr/libexec/git-core:$PATH:$HOME/bin
保存退出,然后用命令从新启动一下这个文件

source/root/.bash_profile

再用git下载你网上的代码就可以了