温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

日常Laravel错误总结

发布时间:2020-07-28 17:47:05 来源:网络 阅读:1145 作者:思梦教育 栏目:web开发

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批量添加报的错

日常Laravel错误总结

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

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+默认使用utf8mb4字符编码,而不是之前的utf8编码。因此运行php artisan migrate 会出现如下错误:

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

/**

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

*

* @return void

*/

public function boot()

{

Schema::defaultStringLength(191);

}


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI