Home > OS >  Laravel (6.0) Route not found error - but route exists in route:list
Laravel (6.0) Route not found error - but route exists in route:list

Time:11-20

I am trying to access a route from a package but I get route not found - even though the route shows when I am using the command php artisan route:list. I have tried clearing all cache but still no success? Everything works fine in my local environment so I am leaning towards a cache issue.

Error message is below:

[previous exception] [object] (Symfony\Component\Routing\Exception\RouteNotFoundException(code: 0): Route [admin.affiliate_urls.index] not defined. at /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:437) [stacktrace] #0 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(777): Illuminate\Routing\UrlGenerator->route() #1 /home/forge/site/storage/framework/views/aed68191b7fd34274389d9db4a4a419e12790000.php(145): route() #2 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/home/forge/www...') #3 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath() #4 /home/forge/site/vendor/facade/ignition/src/Views/Engines/CompilerEngine.php(36): Illuminate\View\Engines\CompilerEngine->get() #5 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/View.php(143): Facade\Ignition\Views\Engines\CompilerEngine->get() #6 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/View.php(126): Illuminate\View\View->getContents() #7 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/View.php(91): Illuminate\View\View->renderContents() #8 /home/forge/site/storage/framework/views/a6b35713f60cfc6d83afb428a6584b18d94c1e22.php(10): Illuminate\View\View->render() #9 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/home/forge/www...') #10 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath() #11 /home/forge/site/vendor/facade/ignition/src/Views/Engines/CompilerEngine.php(36): Illuminate\View\Engines\CompilerEngine->get() #12 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/View.php(143): Facade\Ignition\Views\Engines\CompilerEngine->get() #13 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/View.php(126): Illuminate\View\View->getContents() #14 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/View.php(91): Illuminate\View\View->renderContents() #15 /home/forge/site/vendor/laravel/framework/src/Illuminate/Http/Response.php(42): Illuminate\View\View->render() #16 /home/forge/site/vendor/symfony/http-foundation/Response.php(205): Illuminate\Http\Response->setContent() #17 /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(749): Symfony\Component\HttpFoundation\Response->__construct() #18 /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(721): Illuminate\Routing\Router::toResponse() #19 /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(681): Illuminate\Routing\Router->prepareResponse() #20 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Routing\Router->Illuminate\Routing\{closure}() #21 /home/forge/site/vendor/Company/admingui/src/Middleware/AuthAdminUser.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #22 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Company\Admingui\Middleware\AuthAdminUser->handle() #23 /home/forge/site/vendor/Company/core/src/Middleware/CampaignSession.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #24 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Company\Core\Middleware\CampaignSession->handle() #25 /home/forge/site/vendor/Company/core/src/Middleware/UriRedirect.php(29): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #26 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Company\Core\Middleware\UriRedirect->handle() #27 /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #28 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Routing\Middleware\SubstituteBindings->handle() #29 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #30 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle() #31 /home/forge/site/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #32 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\View\Middleware\ShareErrorsFromSession->handle() #33 /home/forge/site/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #34 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Session\Middleware\StartSession->handle() #35 /home/forge/site/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #36 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle() #37 /home/forge/site/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #38 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Cookie\Middleware\EncryptCookies->handle() #39 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #40 /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(683): Illuminate\Pipeline\Pipeline->then() #41 /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Router->runRouteWithinStack() #42 /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(624): Illuminate\Routing\Router->runRoute() #43 /home/forge/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(613): Illuminate\Routing\Router->dispatchToRoute() #44 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(170): Illuminate\Routing\Router->dispatch() #45 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}() #46 /home/forge/site/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(60): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #47 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle() #48 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #49 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() #50 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #51 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() #52 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #53 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle() #54 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #55 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle() #56 /home/forge/site/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #57 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(171): Fideloper\Proxy\TrustProxies->handle() #58 /home/forge/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() #59 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\Pipeline\Pipeline->then() #60 /home/forge/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() #61 /home/forge/site/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle() #62 {main} "}

Output of php artisan route:list

[...] | | GET|HEAD | admin/affiliate-urls | admin.affiliate_urls.index | Company\Admingui\Controllers\AdminAffiliateUrlController@index | web,admin | [...]

Content of web.php (routes in package)

[...] Route::get('/admin/affiliate-urls','Company\Admingui\Controllers\AdminAffiliateUrlController@index')->name("admin.affiliate_urls.index"); [...]

CodePudding user response:

Given all the other routes work, and the route got added later, it is a cache issue. You could try php artisan route:clear OR php artisan optimize:clear (I prefer the latter since it clears all cache, and not just route). It should start working then.

Note:

  1. *:clear commands do NOT build the cache again.
  2. The optimize command doesn't work with Route closures, so if you have that, you'd have to comment it out and then run the optimize command.

CodePudding user response:

First, clear all cahe & route cache : php artisan optimize Then if it's not working then sea your all Route php artisan route:list

  • Related