您的位置 首页 php

日常Laravel错误总结

1、laravel5.6 Call to a member function format() on string

这个出现在使用模型save()或者update()的使用

解决:在对应得模型文件里面

public function fromDateTime($value)

{

return empty($value) ? $value : $this->getDateFormat();

}

2、出现下面的错误,是使用create批量添加报的错

解决办法:在对应得模型中添加

protected $fillable = [‘name’, ‘age’, ‘sex’];

3、出现以下问题

Sorry, the page you are looking for could not be found.

解决:一般是没加路由,或者路由错误,在或者就是没有模板

4、The page has expired due to inactivity.Please refresh and try again.

解决方法:{{ csrf_field() }} 表单验证

5、在linux下面app/public(如果上传文件在这个目录)/stotage 都给权限

6、使用 composer 下面安装第三方 类库 的时候出现下面问题

[RuntimeException]

/home/wwwroot/lar.simengphp.cn/vendor/psr/http-message does not exist and could not be created.

解决方法:composer dump-autoload

[ErrorException]

file_put_contents(/home/wwwroot/lar.simengphp.cn/vendor/composer/autoload_namespaces.php): failed

to open stream: Permission denied

解决方法:

以上都是linux下权限问题,项目vender没有权限

r:read就是读权限 –数字4表示

w:write就是写权限 –数字2表示

x:excute就是执行权限 –数字1表示

读、写、运行三项权限可以用数字表示,就是r=4,w=2,x=1。所以,-rw-r–r–用数字表示成644。

7、Class config does not exist in

原因是我的.env里面的参数设置有空格。。。有空格的参数一定要用 双引号 包起来

8、1071 Specified key was too long; max key length is 1000 bytes ( SQL : alter table `db_u

sers` add unique `users_email_unique`(`email`))

Laravel 5.4+默认使用 utf8 mb4 字符编码 ,而不是之前的utf8编码。因此运行php artisan migrate 会出现如下错误:

你可以通过调用 AppServiceProvider 中的 Schema ::defaultStringLength 方法来配置它

/**

* 引导任何应用程序服务。

*

* @return void

*/

public function boot()

{

Schema::defaultStringLength(191);

}

文章来源:智云一二三科技

文章标题:日常Laravel错误总结

文章地址:https://www.zhihuclub.com/150260.shtml

关于作者: 智云科技

热门文章

网站地图