laravel5的坑

以此记录学习laravel的一些问题

 

问题:laravel转移文件夹到另外一pc或者环境后访问出现500

设置权限为777

 

问题: 设置路由后页面总是404 not found

解决:需要在apache 配置文件里添加对laravel文件夹的访问

<Directory "D:\WAMP\laravel\public">
    Options Indexes FollowSymLinks
    #

    # AllowOverride controls what directives may be placed in .htaccess files.

    # It can be "All", "None", or any combination of the keywords:

    #   Options FileInfo AuthConfig Limit

    #此处必须为all none不行

    AllowOverride All
    #

    # Controls who can get stuff from this server.

    #

    #Require all granted

    #Allow Order not supported

    Allow from all 

    Require all granted 

</Directory>

 

 

问题:Laravel 5.1Form组建不能安装

解决办法:

先在composer.jsonrequire中加入"laravelcollective/html": "~5.1"

然后composer update

然后config/app.php中加入

 

providers部分

Collective\Html\HtmlServiceProvider::class,

 

aliases部分

'Form' => Collective\Html\FormFacade::class,

'Html'      => Collective\Html\HtmlFacade::class,

  

问题: Laravel 5.1不能发邮件

解决

1. 设置mail.php后删除了evn(), evn表示读取.evn的变量

dd(Config::get('mail'));

2. 输出配置来查看, 更新一次就要清一次cache

php artisan cache:clear

php artisan config:cache

3. 设置成ssl验证

 

我的配置:

array:9 [▼

  "driver" => "smtp"

  "host" => "smtp.163.com"

  "port" => 465

  "from" => array:2 [▼

    "address" => "EMAIL@163.com"

    "name" => "DC"

  ]

  "encryption" => "ssl"

  "username" => "EMAIL@163.com"

  "password" => "PASSWORD"

  "sendmail" => "/usr/sbin/sendmail -bs"

  "pretend" => false

]

发现最近自己解决问题时候总是太急, 结果忽视了应该注意到的地方, 比如输出配置一直也没好好看, 后来仔细看才发现username, password是空导致的问题...

"聪明人用笨办法", 还真是, 更何况咱还不聪明...

有时候慢未必就会慢.

  

问题: 怎么手动清理配置缓存

解决: 命令行可以用php artisan config:cache 

手动可以写个路由, 然后

use Artisan;

public function clearConfigCache() {

    Artisan::call('config:cache');

}

 

问题:Laravel安装后访问错误, 或访问routeview失效,显示了空白页面

解决:

chgrp -R www-data /var/www/laravel  //用户组根据自己的来定义

chmod -R 775 /var/www/laravel/app/storage

 

外键约束字段必须是int 10 UNSIGNED 属性

如果遇到各种莫名奇怪的问题, 清缓存先!!

  

 

问题:composer 不能安装

with这条命令:

    php -r "readfile('https://getcomposer.org/installer');" | php

先进入https://getcomposer.org/installer会下载到一个文件名为installer的文件

 

然后运行php -r "readfile('/www/xx/installer');" | php来读取下载好的文件

 

然后会生成一个composer.phar的文件, 在此文件的目录中运行:

php composer.phar

来执行composer相关命令, php composer.phar update

 

如果php不在环境变量里, 则需要写完整bin路径/opt/php/bin php来替代php

 

ex:

/opt/lampp/bin/php artisan config:cache

  

问题:ajax请求时出现token missing错误

HTML中设置

<meta name="csrf-token" content="{{ csrf_token() }}" />

 

ajax代码前设置

                $.ajaxSetup({

                    headers: {

                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

                    }

                });

  

 

 

 

不错的参考资料:

手册: http://cheats.jesse-obrien.ca/

 

https://github.com/jp7internet/laravel-apz

https://github.com/yccphp/laravel-5-blog

http://9iphp.com/web/laravel

https://phphub.org/topics/804

http://segmentfault.com/a/1190000002505703#articleHeader6

https://phphub.org/topics/537

http://changziming.com/blog/post-167.html

权限解决方案Entrust http://www.poloo.org/?p=1057

http://ofcss.com/2015/03/13/laravel-5-custom-error-pages.html

 

里面有学习视频link http://www.slideshare.net/shengyou/laravel-43453376

posted @ 2015-07-29 14:37  derrck  阅读(5823)  评论(1编辑  收藏  举报