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

cofag's avatar
Level 1

Artisan commands not executing as CLI from code.

I have written the logic to get the user name from DB and used it as URL prefix in my web.php and grouped some routes using those name.

On my local machine it seems to working fine. In case of live server users can registered, but that user is not able to access the further routes as their username as prefix. When tried to access it shows 404.

When did the research it was due to routes not getting cleared. So, after new use registration added the below code clear cache. but still not working. How can i achieve this.

use Illuminate\Support\Facades\Artisan;

Artisan::call('route:clear'); Artisan::call('cache:clear');

0 likes
2 replies
Sinnbeck's avatar

So there is no shell access on the server? How are you trying to call those commands?

cofag's avatar
Level 1

Hey @Sinnbeck I have the shell access but every time i can not use shell to clear cache or routes. it should be done from the code, using artisan command as per docs. Thanks

Please or to participate in this conversation.