Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vural2123's avatar

PHP artisan optimize route error

Hello everyone, I'm new here. When I run the php artisan optimize command, I get the error in the picture, can you please help me? prnt.sc/O9RQDhtYtFoi wtools.io/paste-code/bJdD

0 likes
14 replies
Sinnbeck's avatar

Just copy paste the error message :)

1 like
vural2123's avatar

@LoverToHelp Since the link is forbidden, I uploaded the image to the prnstc site and put the link at the bottom of the topic, and I also uploaded the web.php route file.

Sinnbeck's avatar

@vural2123 first and last routes are duplicates (the resource routes also has destroy

Route::get('roles/destroy/{role}', 'RolesController@destroy')->name('roles.destroy');
 
        //Route::resource('permissions', 'PermissionsController')->middleware('demo');
        Route::post('roles/assign', 'RolesController@assign')->name('roles.assign')->middleware('demo');
        Route::resource('roles', 'RolesController')->middleware('demo');
1 like
Sinnbeck's avatar

Also a get route for destroy does not make sense

vural2123's avatar

@Sinnbeck thank you so much. These are the software I purchased and the developer hasn't responded for a few days. I'm actually not a developer like you. Could you please edit the routes in the link for me?

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@vural2123 just delete the first one

Route::get('roles/destroy/{role}', 'RolesController@destroy')->name('roles.destroy');

Or wait with caching until he responds. It's not that huge an improvement

1 like
vural2123's avatar

@Sinnbeck yes this is successful, thank you very much for your help

[root@server public_html]# php artisan optimize

   INFO  Caching the framework bootstrap files.  

  config ........................................................... 37ms DONE   routes ........................................................... 83ms DONE

[root@server public_html]# 

Sinnbeck's avatar

@vural2123 Happy to help :) Please mark the answer as best to set the thread as solved

1 like
vural2123's avatar

@sinnbeck globalsepet.com/login check my site please. syntax error, unexpected identifier "version" Can you help me?

vural2123's avatar

@Sinnbeck thank you, laracasts.com/discuss/channels/laravel/syntax-error-unexpected-identifier-version

Please or to participate in this conversation.