├── README.md └── _config.yml /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Common Errors Cheatsheet 2 | 3 | ⚡ Laravel Common Error Cheatsheet for beginners. 4 | 5 | 🔍 Use Ctrl + F to search for error 6 | 7 | 🥳 Feel free to contribute 8 | 9 | --- 10 | 11 | **Error 1** 12 | 13 | `SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select count(*) as aggregate from` users`where`email `= xxx@xx.com)` 14 | 15 | **Solution** 16 | 17 | Make sure the database details are correct on the .env file 18 | 19 | DB_CONNECTION=mysql 20 | DB_HOST=127.0.0.1 21 | DB_PORT=3306 22 | DB_DATABASE=your_database_name 23 | DB_USERNAME=your_database_username 24 | DB_PASSWORD=your_database_password 25 | 26 | --- 27 | 28 | **Error 2** 29 | 30 | `419 sorry your session has expired. please refresh and try again` 31 | 32 | or 33 | 34 | `TokenMismatchException` 35 | 36 | **Solution** 37 | 38 | The error basically occurs when there is no csrf token field on the form post. Make sure you have {{ csrf_filed() }} on the blade form. 39 | 40 | --- 41 | 42 | **Error 3** 43 | 44 | `404 45 | Sorry, the page you are looking for could not be found.` 46 | 47 | or 48 | 49 | `NotFoundHttpException` 50 | 51 | **Solution** 52 | 53 | You have not added the Route. Go to routes/web.php and specify the route. 54 | 55 | --- 56 | 57 | **Error 4** 58 | 59 | `405 Method not allowed` 60 | 61 | or 62 | 63 | `MethodNotAllowedHttpException` 64 | 65 | 66 | **Solution** 67 | 68 | You have not added the Route or it is not in Route::post method . Go to routes/web.php and specify the route or modify the route to post method. 69 | 70 | --- 71 | 72 | **Error 5** 73 | 74 | `Class App\Http\Controllers\HomeController does not exist` 75 | 76 | **Solution** 77 | 78 | You have not created the HomeController file. Go to your terminal and run 79 | `php artisan make:controller HomeController` 80 | 81 | --- 82 | 83 | **Error 6** 84 | 85 | `Method App\Http\Controllers\HomeController::test does not exist.` 86 | 87 | **Solution** 88 | 89 | You have not created the specified method on HomeController. Here the test method is not added in HomeController. 90 | 91 | --- 92 | 93 | **Error 7** 94 | 95 | `View [sample] not found.` 96 | 97 | **Solution** 98 | 99 | The template blade file is not present on the specified directory. Make sure you have created the sample.blade.php file on resources/views folder. 100 | 101 | --- 102 | 103 | **Error 8** 104 | 105 | `Class 'App\Http\Controllers\admin\Auth' not found ` 106 | 107 | **Solution** 108 | 109 | To use the Auth Namespace you need to import it at the top. 110 | `Use Auth;` 111 | 112 | --- 113 | 114 | **Error 9** 115 | 116 | `SQLSTATE[HY000] General error: 1364 Field 'email' doesn't have a default value` 117 | 118 | **Solution** 119 | 120 | You need to pass the value to the Model at the time of creating new record. Or you need to make the field nullable in migration ->nullable and run 121 | `php artisan migrate:fresh` 122 | 123 | --- 124 | 125 | **Error 10** 126 | 127 | `ModelNotFoundException` 128 | 129 | **Solution** 130 | 131 | This exception is thrown if you try to access the data that does not exist. Generally thrown by findOrFail() or firstOrFail() 132 | 133 | --- 134 | 135 | **Error 11** 136 | 137 | `Cannot end a section without first starting one` 138 | 139 | This error will be at the blade file. Check that you have a starting of section Eg: `@section('content')` 140 | 141 | ---- 142 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-hacker --------------------------------------------------------------------------------