A boilerplate setup to run a Laravel application using Docker, with Xdebug enabled for local PHP debugging.
- Laravel application running inside Docker containers
- Preconfigured PHP container with Xdebug support
- MySQL / MariaDB database container
- Apache as web server
- Easy host & network configuration
Before you get started, you’ll need:
- Docker (Engine) installed
- Docker Compose installed
- Git
- VSCode + Dev Containers extension (you can try another editor / IDE, but this is the one I used for develop and test it)
- It was tested only in Linux, but I believe it will works fine in Windows too
If you with, you can start a Laravel application in the way you think is better and just copy containers files to your repository, but if you want to use the Laravel application in this repository, here is the step-by-step:
-
Clone the repository
git clone https://github.com/devdiogenes/laravel-docker-xdebug.git cd laravel-docker-xdebug -
Copy
.env.exampleto.envand adjust configuration if neededcp .env.example .env ```. -
Open the folder in VSCode
code . -
Press Ctrl + Shift + P and open it as a dev container
-
Get your MariaDB container name
docker ps
-
Set your MariaDB container name as DB_HOST in .env
-
Open terminal in VSCode (inside remote container)
-
Install PHP dependencies
composer install
-
Generate Laravel application key
docker-compose exec app php artisan key:generate -
Run migrations
php artisan migrate
-
Access your application in the browser
The default URL is typicallyhttp://127.0.0.1
Contributions, issues, and feature requests are welcome.
- Fork the repo
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m "Add some feature") - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
This project is open-sourced software licensed under the MIT License.