Running symfony apps on Windows 10 could be a real pain because it is extremely slow. To solve this issue you can run your symfony app on WSL 2.

Like written above symfony apps are extremely slow when you try to run then on a Windows 10 system. Especially when you run them in the dev environment while development. It doesn’t matter how fast your system is. Loading times for one simple single request could be easily around one till 20 seconds. And this is really not funny at all.

To accelerate it, you can simply get WSL 2 running on your machine and run you app there.

The only thing you have to note is that sharing data between WSL 2 and Windows is terrible slow, too.

To get your symfony app running fast, you have to place your code inside the WSL container and not on Windows itself.
That means you have to place it in the filesystem of WSL and do not work with file shares. Your Windows partitions will be automatically mounted into WSL in the /mnt location. Place your code somewhere in your user directory in WSL, e.g /home/<username>/dev/.
This directory can be also accessed through Windows. But only over a file share. But this is not so significant, that it disturbes development, because from Windows you normally don’t have several thousand file operations at the same time which slows you down like it is when requesting a page of your symfony app.
To access the code directory choosen above, you can add in the Explorer a new network address. From within the Explorer you can reach the files of WSL over \\wsl$. This will display you your available distributions. Choose the one you currently use and click through till you reach the directory where you will place your directory in which you want to place your development files. Now, simply copy the address in the addressbar (e.g. \\wsl$\Ubuntu-20.04\home\<username>) and set it while creating the new network address.

That’s it.

If you work this way you should also use all your console tools like composer, symfony, node, etc. in your WSL container. Your IDE can use your just added network address.

Categories: Symfony