Laravel 7.x View-related exception after config:cache
Hi all,
I am a junior php developer and very new to laravel. I have the following problem. I cached my config with php artisan config:cache, the programm broke with error 500 and in the log i saw the exception shown bellow :
local.ERROR: Method Illuminate\View\View::__toString()
must not throw an exception, caught
Facade\Ignition\Exceptions\ViewException: Route [homepage.get] not defined.
(View: /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/resources/views/static/includes/header.blade.php) {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0):
Method Illuminate\View\View::__toString() must not throw an exception, caught Facade\Ignition\Exceptions\ViewException:
Route [homepage.get] not defined.
(View: /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/resources/views/static/includes/header.blade.php)
at /var/www/vhosts/sotiris.upgrade/httpdocs/command-center/vendor/symfony/http-foundation/Response.php:0).
Routes:
/*
|--------------------------------------------------------------------------
| HOME PAGE
|--------------------------------------------------------------------------
*/
Route::get('/',
[
'as' => 'homepage.get',
'uses' => 'StaticPagesController@getHomePage'
]
);
Screenshot here https://i.stack.imgur.com/rPHB1.png
-bash-4.2$ php artisan route:clear
Route cache cleared!
-bash-4.2$ php artisan config:clear
Configuration cache cleared!
-bash-4.2$
I cleared everything in cache and it worked. Can anyone please help me ? Any steps?? Files to look for ? Anything
Hi there,
I'm just following up on some of the old unanswered questions on the site.
I believe that as of Laravel 7, you should use the name()
method for named routes, eg:
Route::get('user/profile', function () {
//
})->name('profile');
For more information you can take a look at the official documentation here: