Laravel 5.2 Validation Error not appearing in blade
Try to remove web
middleware if you're using 5.2.27 or higher. The thing is now Laravel automatically applies web
middleware to all routes inside routes.php
and if you're trying to add it manually you can get errors.
app/Providers/RouteServiceProvider.php
of the 5.2.27 version now adds web middleware to all routes inside routes.php
:
protected function mapWebRoutes(Router $router)
{
$router->group([
'namespace' => $this->namespace, 'middleware' => 'web',
], function ($router) {
require app_path('Http/routes.php');
});
}
Request Errors not accessible in blade (Laravel 5.2)
@VipindasKS is right with his assumption. Since Laravel Version 5.2.28 the web middleware is included in all routes via the RouteServiceProviders's method:
protected function mapWebRoutes(Router $router)
{
$router->group([
'namespace' => $this->namespace, 'middleware' => 'web',
], function ($router) {
require app_path('Http/routes.php');
});
}
Since that version Laravel's default routes.php file only contains:
Route::get('/', function () {
return view('welcome');
});
So if you upgrade from a previous version, that has a routes.php file like this:
Route::group(['middleware' => ['web']], function () {
// web routes
});
Your application will just work fine, because with an composer update you won't touch your RouteServiceProvider (It does not add the mapWebRoutes() method). So the 'web' middleware is only added to the routes within the 'web' group'.
However if you are pulling a fresh installation of Laravel ( currently 5.2.29 ) and have a routes.php with
Route::group(['middleware' => ['web']], function () {
// web routes
});
The web middleware stack will be added twice to the routes. You can check this via:
php artisan route:list
Which will show that the 'web' middleware is added twice:
| POST | users/{id}/edit | | App\Http\Controllers\UserController@update | web,web |
This breaks the Session's flash variables as they are normally only intended to last only during one session lifecycle.
So the solution is:
Don't use the 'web' middleware group in the routes.php file if you
pulled a fresh instance of laravel.
Laravel 7.5.2 $errors not displaying on blade
I made a new Laravel project and copy and pasted the views and routes to the new Laravel project and make a new controllers again and it works. No changes to the code was made
Related Topics
PHP Read_Exif_Data and Adjust Orientation
How to Use "Dependency Injection" in Simple PHP Functions, and Should I Bother
How to Find Unused Functions in a PHP Project
Setting Environment Variables for Accessing in PHP When Using Apache
What Does "Zend_Mm_Heap Corrupted" Mean
How to Alias a Table in Laravel Eloquent Queries (Or Using Query Builder)
Upload a File Using File_Get_Contents
Laravel Socialite: Invalidstateexception
How to Enable PHP's Openssl Extension to Install Composer
Laravel Eloquent Sum of Relation's Column
Reconstruct/Get Source Code of a PHP Function
How to Extract Links and Titles from a .HTML Page