The development environment is fully containerized using Docker and Laravel Sail.
- mateusjunges/laravel-kafka: This package provides a nice way of producing and consuming kafka messages in your Laravel projects.
-
Setup the environment.
composer setup
-
Build and start the application containers.
sail build sail up -d
-
Run migrations and seed data.
sail artisan migrate:fresh --seed
-
Create Kafka topics.
make kafka-create-topics
-
Run Kafka consumers.
sail artisan kafka:tasks-consumer sail artisan kafka:comments-consumer
-
Start the frontend development server.
sail yarn dev
- Pint: Fix code style issues.
sail pint
- PHPStan: Run static analysis to find potential bugs.
sail phpstan analyse
- ESLint: Lint and format frontend code.
sail yarn lint
sail up -d
sail shell
make test-
Topics:
tasks.status.updated— task status changes.comments.created— comment creation.
-
Producers (Laravel):
App\Kafka\Producers\TaskStatusProducer— publishes totasks.status.updatedwhen the task status changes.App\Kafka\Producers\CommentCreatedProducer— publishes tocomments.createdwhen a comment is created.
-
Consumers (Artisan commands):
php artisan kafka:tasks-consumer(group:task-status-consumers)php artisan kafka:comments-consumer(group:comments-consumers)- For DEV, both consumers output useful logs of received payloads to STDOUT.
-
Broadcasting in Soketi:
- Events from consumers are broadcast via Laravel Broadcast:
App\Events\TaskStatusUpdatedBroadcast→ channelproject.{project_id}→ event.task-status-updated.App\Events\TaskCommentCreatedBroadcast→ channelproject.{project_id}→ event.comment-created.
- The frontend subscribes to the required project channel and updates the UI.
- Events from consumers are broadcast via Laravel Broadcast:
./vendor/bin/sail logs -f soketi- Consumers should be run under Supervisor/systemd with autorestart and logging.
- Scaling is achieved through consumer groups (numprocs > 1) and topic partitions.