This repository provides an example of how to set up a Laravel application with Redis queues and a MySQL database using Docker. The application includes a simple job that sends an email, with email testing facilitated by Mailpit.
- Laravel Application: A basic Laravel setup.
- Redis for Queues: Using Redis for managing Laravel queues.
- MySQL Database: A MySQL database for persistent storage.
- Mailpit: An email testing tool to capture and inspect outgoing emails.
- NGINX: Serving the Laravel application.
- Docker installed on your system.
- Docker Compose installed on your system.
- 
Clone the Repository git clone https://github.com/thekubera/laravel-queue-example cd laravel-queue-example
- 
Copy .env.example to .env cp .env.example .env 
- 
Build the Docker Containers Build the containers without using the cache to ensure all dependencies are fresh. docker compose build --no-cache 
- 
Run the Docker Containers Start the containers in detached mode. docker compose up 
- 
Generate Laravel Application Key Open another terminal window and run the following command to generate laravel application key docker compose exec app php artisan key:generate
- 
Run Migrations Run the Laravel migrations to set up the database schema. docker compose exec app php artisan migrate
- 
Access the Application Open your browser and go to http://localhost:8000.
- 
Send an Email Visit http://localhost:8000/send-emailto trigger an email being sent. You should see a message indicating the email has been queued.
- 
Check the Email with Mailpit Open your browser and go to http://localhost:8025to access Mailpit. Here you can see the captured email.
- app: The main Laravel application container.
- queue: A worker container that processes the Laravel queues.
- web: An NGINX container that serves the Laravel application.
- db: A MySQL database container.
- redis: A Redis container for queue management.
- mailpit: A container for capturing and inspecting outgoing emails.
To stop and remove all running containers:
docker-compose down- 
Ensure all environment variables in .envare set correctly.
- 
Check the logs of the containers if you encounter issues: docker-compose logs -f 
- 
Verify that Docker and Docker Compose are properly installed and running. 
This project is open-source and available under the MIT License.
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.
This setup is inspired by various resources and tutorials on Docker, Laravel, and Redis integration.
Happy coding!