日常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批量添加報的錯

日常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);

}


分享到:


相關文章: