K
K
Konstantin Eliseev2020-09-23 14:40:24
Laravel
Konstantin Eliseev, 2020-09-23 14:40:24

Why might new routes not work in Laravel until the server is restarted when running a command from the console?

Wrote the route route('admin.zzz'). The controller has a function that adds a job to the queue. The queue is stored in Redis and executed through the Supervisor. In general, when the supervisor starts the task, an error occurs with the absence of a route.

1) Running php artisan route:clear on the server does not help
2) php artisan route:list contains addressing admin.zzz
3) On the local machine in the docker - everything works
4) There is no cached routes.php file in the bootstrap/cache/ directory
5) It helps to restart the server. The route becomes working...

In general, everything works and sends on the local server, but on the combat server, the new written routes do not work:

//routes/web.php
Route::group(
    [
        'prefix' => 'admin',
        'as' => 'admin.',
        'namespace' => 'Admin',
        'middleware' => ['auth', 'can:admin-panel'],
    ],
    function () {
        Route::get('/', '[email protected]')->name('home');
        Route::get('zzz', '[email protected]')->name('zzz');
    }
);

php artisan route:list
GET|HEAD | admin/zzz | admin.zzz | App\Http\Controllers\Admin\[email protected] | web
GET|HEAD | admin| admin.home | App\Http\Controllers\Admin\[email protected] | web

Symfony\Component\Routing\Exception\RouteNotFoundException: Route [admin.zzz] not defined. in .../vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:420
Stack trace:
#0 /SITE_PATH/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(768): Illuminate\Routing\UrlGenerator->route('admin.zzz', Array, true)
#1 /SITE_PATH/storage/framework/views/0816a56a4590e34f2df710e5cc3160f4c1637bdb.php(5): route('admin.zzz')
#2 /SITE_PATH/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(41): include('/home/birzhalom...')
#3 /SITE_PATH/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(57): Illuminate\View\Engines\PhpEngine->evaluatePath('/home/birzhalom...', Array)
#4 /SITE_PATH/vendor/laravel/framework/src/Illuminate/View/View.php(139): Illuminate\View\Engines\CompilerEngine->get('/home/birzhalom...', Array)
#5 /SITE_PATH/vendor/laravel/framework/src/Illuminate/View/View.php(122): Illuminate\View\View->getContents()
#6 /SITE_PATH/vendor/laravel/framework/src/Illuminate/View/View.php(91): Illuminate\View\View->renderContents()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2020-09-23
@Alex_Wells

Remove the dot from 'as' => 'admin.'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question