Run Laravel Sail in PhpStorm
Streamlining Development with PhpStorm: Use your IDE to run Laravel Sail for a better experience.
March 24, 2023
2k ViewsUsing PhpStorm to manage your processes and commands has numerous advantages over relying solely on the command line and multiple shell windows. By incorporating a running Sail instance within your Integrated Development Environment (IDE), you can streamline your workflow and enjoy many convenient features.
Setting up Sail in WSL2
We first need to install Laravel Sail.
If you want to see how to set up Sail in WSL2 you can visit:
Getting Started With Laravel and WSL2
Configuring to run Sail
- 🔍 In the main menu, navigate to
Run|Edit Configurations
. - 🐳 Then select the
Docker-compose
template. - ✏️ Change the name of the Run Configuration to
dev
or something equivalent. - 📁 Select the Docker Compose file by clicking the Folder icon.
- ➕ Add a Docker Compose configuration file by clicking the
+
icon - 🔎 Browse to the
docker-compose.yml
file in your project directory. - 🆗 Press
OK
to close the file dialog. - 🆗 Press
OK
to close the Run/Debug Configurations dialog - 🚀 In the main menu bar, select the new run configuration and press the start button.
- 🌐 Go to your localhost in your browser.
⚠️ Potential Problems
You may encounter an error in your browser: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied
. You can find more information about correcting this error by reading this article:
Fixing Permission Errors with Laravel Sail
Bonus
If you are interested in choosing the services Sail configures, check this article out: