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

farzad98a's avatar

Laravel runs very slowly on Windows. (Solved)

Laravel Version: 11.31.0

PHP Version: 8.3.14

Database Driver & Version: MariaDB 11.4 on Windows 11

Description:

Laravel runs very slowly on Windows compared to WSL and standalone Ubuntu, and sometimes the following error occurs:

PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\Users\myuser\PhpstormProjects\myproject\vendor\symfony\finder\Iterator\SortableIterator.php on line 51

This problem only exists in the development environment and on Windows. When I run the same project on WSL or Standalone Ubuntu, there is no problem. Also, this problem does not occur in the server and production environment.

The php.ini values ​​are the same in all three environments.

I did some searching and found similar errors related to iterators and it was said that changing the session driver would solve it. I also changed the SESSION_DRIVER and CACHE_STORE to Redis. But the problem still persists.

If it helps, I use Livewire and MaryUI.

Steps To Reproduce:

To be honest, I don't know exactly how to reproduce this problem. The project is nothing special and is a simple store. It has nothing more than Laravel built-in authentication system and a few CRUD and checkout operations.

Is there a way to find out exactly which part of the code this error occurs during execution?

0 likes
10 replies
farzad98a's avatar

@jlrdw I couldn't see anything suspicious. Other than it just saying the first request takes a long time. I even commented out all the database related operations. But nothing changed.

JussiMannisto's avatar

Take a look at the full stack trace, and follow it to find out which part of your code causes it. That might give you an idea as to what's happening.

1 like
farzad98a's avatar

@JussiMannisto There is no traceback and only this error is displayed and unfortunately it is not clear what part of the code is causing this.

Tray2's avatar

Most likely you dev setup has a timeout limit set to 30s, while your other environments have the standard 60s.

Like @jlrdw says, install a debugbar, to see if it is a slow running query or something else.

There could be several things that might cause this.

  1. Slow queries causing the timeout
  2. Windows preventing you from accessing things on localhost
  3. Poorly written code, filtering things with php instead of harnessing the database
  4. Xampp/Wamp installed in other directory than C:\xampp or C:\wamp

You don't say what you are using to host your dev environment, but I would suggest using Laravel Herd to host it, rather than using xampp, wamp, or whatever else there is out there.

1 like
farzad98a's avatar

@Tray2 No, I don't use anything special and I installed everything separately. I think if what you mentioned is true, this problem should exist in other operating systems as well. But it doesn't. This problem only exists in Windows. So maybe the second thing you mentioned is correct.

farzad98a's avatar
farzad98a
OP
Best Answer
Level 1

The problem was solved by running the "php artisan optimize" command. Also to further increase speed, I added all the directories and processes related to IDE, PHP, MariaDB, and Memuari (Redis) to the Windows Defender exclusions

JussiMannisto's avatar

@farzad98a That command just caches config and routes, and compiles Blade views. It couldn't have fixed your 30s timeout bug. If the bug went away, it must've been because of some other change.

farzad98a's avatar

@JussiMannisto I tested it several times and even adding processes and directories to the Windows Defender exclusions wasn't very effective. To be more specific, the blade icons were causing this slowdown. According to the https://github.com/blade-ui-kit/blade-icons#caching blade icons should be cached. To make sure of this, I ran the "php artisan optimize:clear" command once and then ran the "php artisan icons:cache command" and saw that the slowdown problem was solved.

Please or to participate in this conversation.