PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Unsolved

Laravel 7.x View-related exception after config:cache

sotiris-zois

Apr 21st, 2020 06:40 AM

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

bobbyiliev

Sep 8th, 2022 10:02 PM

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: