12/08/2018, 16:09

Một số lỗi cơ bản gặp khi làm việc với laravel framework

RuntimeException in EncryptionServiceProvider.php line 29: No supported encrypter found. The cipher and / or key length are invalid in EncryptionServiceProvider.php line 29 at EncryptionServiceProvider->IlluminateEncryption{closure}(object(Application), array()) in ...

RuntimeException in EncryptionServiceProvider.php line 29:						
No supported encrypter found. The cipher and / or key length are invalid						
in EncryptionServiceProvider.php line 29						
at EncryptionServiceProvider->IlluminateEncryption{closure}(object(Application), array()) in Container.php line 733						
at Container->build(object(Closure), array()) in Container.php line 626						
at Container->make('encrypter', array()) in Application.php line 674						
at Application->make('IlluminateContractsEncryptionEncrypter') in Container.php line 837						
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 800						
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 771						
at Container->build('SahraSalonHttpMiddlewareEncryptCookies', array()) in Container.php line 626						
at Container->make('SahraSalonHttpMiddlewareEncryptCookies', array()) in Application.php line 674						
.....
  • solution: chạy command php artisan key:generate

Whoops, looks like something went wrong
Warning: require(D:xampphtdocsLaravel-5-Bootstrap-3-Starter-Site-masterootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in D:xampphtdocsLaravel-5-Bootstrap-3-Starter-Site-masterootstrapautoload.php on line 17

Fatal error: require(): Failed opening required 'D:xampphtdocsLaravel-5-Bootstrap-3-Starter-Site-masterootstrap/../vendor/autoload.php' (include_path='D:xamppphpPEAR') in D:xampphtdocsLaravel-5-Bootstrap-3-Starter-Site-masterootstrapautoload.php on line 17
  • solution: kiểm đã có file .env trong thư mục source gốc chưa, có thể chạy lệnh php artisan key:generate

Unexpected Exception: SQLSTATE[HY000] [1045] Access denied for user ****@'localhost' (using password: YES)

  • solution: kiểm tra lại lại thông tin connection DB_USERNAME, DB_PASSWORD trong file .env hoặc trong config/database.php

  [ReflectionException]
  Class UsersTableSeeder does not exist

  • bạn vừa tạo 1 class , check đi check lại thấy đúng đường dẫn, đúng tên, đúng đuôi file, mà vẫn báo lỗi này thì câu lệnh sau có thể giúp bạn composer dump-autoload

TokenMismatchException in VerifyCsrfToken.php line 68:

  • chưa có token trong form khi submit, thêm code sau vào <form>...</form>

{{ csrf_field() }}
  • chưa có token khi gửi ajax jquery , cài đặt axjax header:

$.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
NotFoundHttpException in RouteCollection.php
  • lỗi thư mục không có quyền

sudo chmod -R 777 storage
sudo chmod -R 777 bootstrap/cache
[IlluminateDatabaseQueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
  • sửa trong file AppServiceProvider.php

use IlluminateSupportFacadesSchema;
.....
public function boot()
{
Schema::defaultStringLength(191);
}
0