This guide walks you through creating a Laravel backend and a Next.js frontend, all within a Dockerized environment. You can have everything up and running in just a few minutes.
- Docker and Docker Compose installed on your system
- Basic knowledge of Laravel and Next.js
- Basic knowledge of command-line usage
git clone https://github.com/softjapan/laravel-nextjs-dev-environment.gitBy default, this setup uses MySQL. We will skip running migrations at this point and do them later. Other options use default settings.
cd laravel-nextjs-dev-environment
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev laravel new laravel-backendWe will install Laravel Breeze (API scaffolding) without running migrations at this stage. Migrations will be run later after configuring the .env file and starting the Docker containers.
cd laravel-backend
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev composer require laravel/breeze --dev
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev php artisan breeze:install apicd ..
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev git clone https://github.com/laravel/breeze-next.git next-frontendcd next-frontend
docker run --rm -it -v "$PWD:/app" softjpn/laravel-nodejs-dev npm installThese files contain database connection details and other environment variables.
cd ..
cp ./envfiles/laravel-backend/.env ./laravel-backend/.env
cp ./envfiles/next-frontend/.env ./next-frontend/.envdocker compose up -dOnce the containers are running and your .env files are in place, apply the migrations:
docker exec -it laravel-backend php artisan migrateOpen your browser and navigate to:
http://localhost:3000
When you’re done, shut down the containers:
docker compose downThis project is open source and available under the MIT License.
Contributions are welcome! Feel free to open a pull request with improvements or suggestions.
For questions or additional support, please open an issue in this repository.
Enjoy your streamlined Laravel + Next.js development setup!
