Getting Started › Introduction

NestLaravel

The Nx + Laravel microservice framework with Kafka.

NestLaravel gives you a monorepo where every backend microservice is a real Laravel application, all of them sit behind one hardened API gateway, and they talk to each other through Apache Kafka using a single, versioned event contract. Nx orchestrates builds, tests and the dependency graph; the nestlaravel CLI scaffolds and upgrades everything.

npx nestlaravel create my-project
cd my-project
npx nestlaravel generate service orders
npx nestlaravel dev

#Why NestLaravel

You wantNestLaravel gives you
Laravel's productivity per serviceEach service is a normal Laravel app with a Domain / Application / Infrastructure / Presentation module
One front doorapps/api is the only public interface: authentication, rate limiting, routing
Services that cannot be bypassedGateway → service calls are HMAC-signed; services reject anything else (fail closed)
Reliable async messagingTransactional outbox, acks=all + idempotent producer, manual-commit consumer, retries, dead-letter topics, idempotent handlers
A repeatable workflowcreate, generate service, generate kafka-event, dev, test, build, update
Optional multi-tenancynestlaravel add tenancy — tenant-scoped Eloquent, jobs, cache, storage and Kafka events

#Architecture at a glance

                  Browser / mobile / third parties
                                │  HTTPS
                     ┌──────────▼───────────┐   PUBLIC
                     │  apps/api  (gateway) │   auth · rate limits · CORS · routing
                     └───┬──────────────┬───┘
        HMAC-signed HTTP │              │ HMAC-signed HTTP          INTERNAL (no public ports)
              ┌──────────▼───┐      ┌───▼──────────┐
              │ orders-service│      │ payments-svc │  … your services (Laravel)
              │  own database │      │ own database │
              └──────┬────────┘      └──────┬───────┘
                     │  events (outbox)     │
                     └────────►  Kafka  ◄───┘     SERVICE-TO-SERVICE

Read next: INSTALLATION.md · ARCHITECTURE.md · CLI.md · MICROSERVICES.md · KAFKA.md · SECURITY.md · DEPLOYMENT.md · UPGRADING.md · MULTI-TENANCY.md · CONTRIBUTING.md · CHANGELOG.md

#Requirements

MinimumTested
Node.js20.1120, 22, 24
PHP8.3 (mbstring openssl pdo tokenizer xml ctype json fileinfo bcmath)8.3, 8.4
Composer2.62.x
Dockerrecommended (Kafka, Postgres, Redis, image builds)Docker Engine / Desktop 27+
Kafka3.6+ (KRaft)dev image apache/kafka:4.0.0
Redis7+7
PostgreSQL / MySQL / SQLite15+ / 8+ / 3Postgres 16

Laravel ^13.30, Nx ^23.2. php-rdkafka is needed to reach a real broker from PHP — the Docker images include it; on a bare host the framework falls back to a log/null driver.

#Repository layout (this repo is the framework source)

apps/api                  gateway (public)                    packages/cli            the `nestlaravel` npm package
apps/*-service            reference microservices             packages/laravel-kafka  Kafka kit (Composer package)
apps/*-portal             optional Next.js portals            packages/laravel-tenancy optional multi-tenancy package
infrastructure/           Dockerfile, scripts, Postgres init  docs/                   topic guides

Legacy topic guides (modules, queues, redis, portals, …) remain in docs/.

#Development of the framework itself

npm install                                  # Nx
(cd apps/api && composer install && php vendor/bin/phpunit)
(cd packages/laravel-kafka && composer install && php vendor/bin/phpunit)
(cd packages/laravel-tenancy && composer install && php vendor/bin/phpunit)
(cd packages/cli && npm test)

See CONTRIBUTING.md and the release process in DEPLOYMENT.md.

#License

MIT — see LICENSE.

Edit this page on GitHub