Search code examples
phplaravellaravel-artisan

PHP artisan serve command commits changes very slowly


Whenever I try to update my project in Artisan, the commands I run work, but some of them take a very long time to execute.

For instance, here is a section from my api.php:

Route::apiResource('questions', 'QuestionController');

php artisan serve works in my terminal, and this route is accessible.

But when I delete this questions route, I expect the route host/questions to become inaccessible. However for about a minute after running the command, I can still access the route through the normal URL as if it wasn't deleted.

So what exactly is going on here? Is this caused by caching, and if so, how can I prevent this?

I want a leave-reload thing for my Laravel project.

I'm recompiling my files using ctrl+c, php artisan serve every time, and using Laravel 5.8 with PHP 7.3.7.


Solution

  • This is probably because Opcache keeps a copy of the files for a moment. Try to disable opcahe and try again.

    Check php.ini and see if opcache.enable is on "1", if so, change it to 0, and restart php artisan serve