|
1 |
| -<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p> |
| 1 | +# Laravel Queue Example with Docker |
2 | 2 |
|
3 |
| -<p align="center"> |
4 |
| -<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a> |
5 |
| -<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a> |
6 |
| -<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a> |
7 |
| -<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a> |
8 |
| -</p> |
| 3 | +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. |
9 | 4 |
|
10 |
| -## About Laravel |
| 5 | +## Features |
11 | 6 |
|
12 |
| -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: |
| 7 | +- **Laravel Application**: A basic Laravel setup. |
| 8 | +- **Redis for Queues**: Using Redis for managing Laravel queues. |
| 9 | +- **MySQL Database**: A MySQL database for persistent storage. |
| 10 | +- **Mailpit**: An email testing tool to capture and inspect outgoing emails. |
| 11 | +- **NGINX**: Serving the Laravel application. |
13 | 12 |
|
14 |
| -- [Simple, fast routing engine](https://laravel.com/docs/routing). |
15 |
| -- [Powerful dependency injection container](https://laravel.com/docs/container). |
16 |
| -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. |
17 |
| -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). |
18 |
| -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). |
19 |
| -- [Robust background job processing](https://laravel.com/docs/queues). |
20 |
| -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). |
| 13 | +## Getting Started |
21 | 14 |
|
22 |
| -Laravel is accessible, powerful, and provides tools required for large, robust applications. |
| 15 | +### Prerequisites |
23 | 16 |
|
24 |
| -## Learning Laravel |
| 17 | +- Docker installed on your system. |
| 18 | +- Docker Compose installed on your system. |
25 | 19 |
|
26 |
| -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. |
| 20 | +### Setup |
27 | 21 |
|
28 |
| -You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. |
| 22 | +1. **Clone the Repository** |
29 | 23 |
|
30 |
| -If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. |
| 24 | + ```sh |
| 25 | + git clone https://github.com/thekubera/laravel-queue-example |
| 26 | + cd laravel-queue-example |
| 27 | + ``` |
31 | 28 |
|
32 |
| -## Laravel Sponsors |
| 29 | +2. **Copy .env.example to .env** |
33 | 30 |
|
34 |
| -We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com). |
| 31 | + ```sh |
| 32 | + cp .env.example .env |
| 33 | + ``` |
35 | 34 |
|
36 |
| -### Premium Partners |
| 35 | +3. **Build the Docker Containers** |
37 | 36 |
|
38 |
| -- **[Vehikl](https://vehikl.com/)** |
39 |
| -- **[Tighten Co.](https://tighten.co)** |
40 |
| -- **[WebReinvent](https://webreinvent.com/)** |
41 |
| -- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** |
42 |
| -- **[64 Robots](https://64robots.com)** |
43 |
| -- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** |
44 |
| -- **[Cyber-Duck](https://cyber-duck.co.uk)** |
45 |
| -- **[DevSquad](https://devsquad.com/hire-laravel-developers)** |
46 |
| -- **[Jump24](https://jump24.co.uk)** |
47 |
| -- **[Redberry](https://redberry.international/laravel/)** |
48 |
| -- **[Active Logic](https://activelogic.com)** |
49 |
| -- **[byte5](https://byte5.de)** |
50 |
| -- **[OP.GG](https://op.gg)** |
| 37 | + Build the containers without using the cache to ensure all dependencies are fresh. |
51 | 38 |
|
52 |
| -## Contributing |
| 39 | + ```sh |
| 40 | + docker compose build --no-cache |
| 41 | + ``` |
| 42 | + |
| 43 | +4. **Run the Docker Containers** |
| 44 | + |
| 45 | + Start the containers in detached mode. |
| 46 | + |
| 47 | + ```sh |
| 48 | + docker compose up |
| 49 | + ``` |
| 50 | + |
| 51 | +5. **Run Migrations** |
| 52 | + |
| 53 | + Run the Laravel migrations to set up the database schema. |
| 54 | + |
| 55 | + ```sh |
| 56 | + docker compose exec app php artisan migrate |
| 57 | + ``` |
| 58 | + |
| 59 | +### Using the Application |
| 60 | + |
| 61 | +1. **Access the Application** |
| 62 | + |
| 63 | + Open your browser and go to `http://localhost:8000`. |
| 64 | + |
| 65 | +2. **Send an Email** |
| 66 | + |
| 67 | + Visit `http://localhost:8000/send-email` to trigger an email being sent. You should see a message indicating the email has been queued. |
| 68 | + |
| 69 | +3. **Check the Email with Mailpit** |
53 | 70 |
|
54 |
| -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). |
| 71 | + Open your browser and go to `http://localhost:8025` to access Mailpit. Here you can see the captured email. |
55 | 72 |
|
56 |
| -## Code of Conduct |
| 73 | +### Docker Compose Services |
| 74 | + |
| 75 | +- **app**: The main Laravel application container. |
| 76 | +- **queue**: A worker container that processes the Laravel queues. |
| 77 | +- **web**: An NGINX container that serves the Laravel application. |
| 78 | +- **db**: A MySQL database container. |
| 79 | +- **redis**: A Redis container for queue management. |
| 80 | +- **mailpit**: A container for capturing and inspecting outgoing emails. |
| 81 | + |
| 82 | +### Stopping the Application |
| 83 | + |
| 84 | +To stop and remove all running containers: |
| 85 | + |
| 86 | +```sh |
| 87 | +docker-compose down |
| 88 | +``` |
| 89 | + |
| 90 | +### Troubleshooting |
| 91 | + |
| 92 | +- Ensure all environment variables in `.env` are set correctly. |
| 93 | +- Check the logs of the containers if you encounter issues: |
| 94 | + |
| 95 | + ```sh |
| 96 | + docker-compose logs -f |
| 97 | + ``` |
| 98 | + |
| 99 | +- Verify that Docker and Docker Compose are properly installed and running. |
| 100 | + |
| 101 | +### License |
| 102 | + |
| 103 | +This project is open-source and available under the [MIT License](LICENSE). |
| 104 | + |
| 105 | +## Contributing |
57 | 106 |
|
58 |
| -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). |
| 107 | +If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome. |
59 | 108 |
|
60 |
| -## Security Vulnerabilities |
| 109 | +## Acknowledgments |
61 | 110 |
|
62 |
| -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. |
| 111 | +This setup is inspired by various resources and tutorials on Docker, Laravel, and Redis integration. |
63 | 112 |
|
64 |
| -## License |
65 | 113 |
|
66 |
| -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
| 114 | +<b>Happy coding!</b> |
0 commit comments