PHPackages                             lucid-arch/laravel-microservice - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. lucid-arch/laravel-microservice

AbandonedArchivedProject[Framework](/categories/framework)

lucid-arch/laravel-microservice
===============================

The Laravel Framework implemented using the Lucid Architecture - as a Microservice.

v8.0.0(5y ago)19373737MITPHPPHP ^7.3

Since Sep 13Pushed 5y ago4 watchersCompare

[ Source](https://github.com/lucid-architecture/laravel-microservice)[ Packagist](https://packagist.org/packages/lucid-arch/laravel-microservice)[ Patreon](https://www.patreon.com/mulkave)[ RSS](/packages/lucid-arch-laravel-microservice/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (12)Versions (20)Used By (0)

Lucid • Microservice - Laravel
==============================

[](#lucid--microservice---laravel)

With the emerging need for separation per concern, microservices emerged to be the trending progression of what used to be a monolithic application. Especially with Lucid, scale is one of the core concerns that a microservice is the natural progression of the architecture from its [monolithic counterpart](https://github.com/lucid-architecture/laravel).

It is no coincidence that the different parts of a Lucid monolithic application are called a **Service**, for microservices are indeed the next progression when applications scale and reach that turning point. Having implemented your application using Lucid, the transition process will be logically simpler to think about and physically straight-forward to implement.

To see how it compares to the monolithic application and when to use which, check [Monolith vs. Microservice](#monolith-vs-microservice)

### Join The Community on Slack

[](#join-the-community-on-slack)

[![Slack Status](https://camo.githubusercontent.com/adbc3f8b115256b1f7d83558eee9fa9fec5a7a8950401349c3d2079fb5f8d88f/68747470733a2f2f6c756369642d736c61636b2e6865726f6b756170702e636f6d2f62616467652e737667)](https://lucid-slack.herokuapp.com)

##### The Lucid Architecture for Building Scalable Applications - Laracon EU 2016

[](#the-lucid-architecture-for-building-scalable-applications---laracon-eu-2016)

Check out my talk at LaraconEU 2016 where I introduce the concept and application of the Lucid architecture: [![Abed Halawi - The Lucid Architecture for Building Scalable Applications](https://camo.githubusercontent.com/3ceb86e33432a37d972222ba2b58cdcf85eddce795c09a247725523aaf717d11/687474703a2f2f696d672e796f75747562652e636f6d2f76692f77536e4d344a6b797850772f302e6a7067)](http://www.youtube.com/watch?v=wSnM4JkyxPw "Abed Halawi - The Lucid Architecture for Building Scalable Applications")

Installation
------------

[](#installation)

To get rolling, you need to create a new project using Composer:

```
composer create-project lucid-arch/laravel-microservice my-project

```

Getting Started
---------------

[](#getting-started)

This project ships with the [Lucid Console](https://github.com/lucid-architecture/laravel-console) which provides an interactive user interface and a command line interface that are useful for scaffolding and exploring Services, Features and Jobs.

### Setup

[](#setup)

The `lucid` executable will be in `vendor/bin`. If you don't have `./vendor/bin/` as part of your `PATH` you will need to execute it using `./vendor/bin/lucid`, otherwise add it with the following command to be able to simply call `lucid`:

```
export PATH="./vendor/bin:$PATH"

```

For a list of all the commands that are available run `lucid` or see the [CLI Reference](https://github.com/lucid-architecture/laravel-console).

### 1. Create a Feature

[](#1-create-a-feature)

This is the Feature that we will be serving when someone visits our `/users` route.

```
lucid make:feature ListUsers

```

### 2. Create a Job

[](#2-create-a-job)

This Job will fetch the users from the database and will be used inside our Feature to serve them.

```
lucid make:job GetUsers user

```

Open the file that was generated at `app/Domains/User/GetUsersJob.php` and edit the `handle` method to this:

```
public function handle()
{
    return [
        ['name' => 'John Doe'],
        ['name' => 'Jane Doe'],
        ['name' => 'Tommy Atkins'],
    ];
}
```

In a real-world application you might want to fetch the users from a database, and here is the perfect place for that. Here's an example of fetching a list of users and providing the ability to specify the limit:

```
use App\Data\Models\User;

class GetUsersJob extends Job
{
    private $limit;

    public function __construct($limit = 25)
    {
        $this->limit = $limit;
    }

    public function handle(User $user)
    {
        return $user->take($this->limit)->get();
    }
}
```

> NOTE: The namespace for models is `[app namespace]\Data\Models`

### 3. Run The Job

[](#3-run-the-job)

```
// ...
use App\Domains\User\GetUsersJob;
use App\Domains\Http\RespondWithJsonJob;
// ...
public function handle(Request $request)
{
    $users = $this->run(GetUsersJob::class);

    return $this->run(new RespondWithJsonJob($users));
}
```

The `RespondWithJsonJob` is one of the Jobs that were shipped with this project, it lives in the `Http` domain and is used to respond to a request in structured JSON format.

### 4. Serve The Feature

[](#4-serve-the-feature)

To be able to serve that Feature we need to create a route and a controller that does so.

Generate a plain controller with the following command

```
lucid make:controller user

```

And we will have our `UserController` generated in `app/Http/Controllers/UserController.php` which we will use to serve our Feature in its `index` method.

We just need to create a route that would delegate the request to our `index` method:

```
// ...
use App\Features\ListUsersFeature;
// ...
class UserController extends Controller
{
    public function index()
    {
        return $this->serve(ListUsersFeature::class);
    }
}
```

In `routes/web.php` add:

```
Route::get('/users', 'UserController@index');
```

That's it! Now serve the application with `php artisan serve` and visit `http://localhost:8000/users`

### Event Hooks

[](#event-hooks)

Lucid exposes event hooks that allow you to listen on each dispatched feature, operation or job. This is especially useful for tracing:

```
use Illuminate\Support\Facades\Event;
use Lucid\Foundation\Events\FeatureStarted;
use Lucid\Foundation\Events\OperationStarted;
use Lucid\Foundation\Events\JobStarted;

Event::listen(FeatureStarted::class, function (FeatureStarted $event) {
    // $event->name
    // $event->arguments
});

Event::listen(OperationStarted::class, function (OperationStarted $event) {
    // $event->name
    // $event->arguments
});

Event::listen(JobStarted::class, function (JobStarted $event) {
    // $event->name
    // $event->arguments
});
```

---

Monolith vs. Microservice
-------------------------

[](#monolith-vs-microservice)

In the monolith Lucid application we have multiple services (i.e. Api, Web) and these typically will exist in `src/Services/Api` and `src/Services/Web` respectively. With the microservice the `src` does not exist, since it is intended to be one service serving a single purpose, the `app` directory will do. It will hold the following directories:

- **Data** For all your models, repositories and value objects.
- **Domains** Holds the Domains and their Jobs.
- **Features** The service's Features.

### Directory Structure

[](#directory-structure)

ComponentMonolithMicroserviceJobsrc/Domains/\[domain\]/Jobs/\[job\]app/Domains/\[domain\]/Jobs/\[job\]Featuresrc/Services/\[service\]/Features/\[feature\]app/Features/\[feature\]Servicesrc/Service/\[service\]N/A (app) as equivalent### Tests

[](#tests)

One other significant difference is in the location of tests:

ComponentMonolithMicroserviceJobsrc/Domains/\[domain\]/Tests/Jobs/\[JobTest\]tests/Domains/\[domain\]/Jobs/\[JobTest\]Featuresrc/Services/\[service\]/Tests/Features/\[FeatureTest\]tests/Features/\[Feature\]Test.phpHow To Choose
-------------

[](#how-to-choose)

It is always [recommended](http://martinfowler.com/bliki/MonolithFirst.html) that you start with a monolith and work on it until it gets so big that it is crucial to be dissected into single-purpose services (microservices). It would be challenging to be able to figure out the different services your application would need moving forward.

This project is also useful when you know for sure that your application will not have to deal with multiple Services but you would still like to use Lucid.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~82 days

Recently: every ~4 days

Total

19

Last Release

2100d ago

Major Versions

v5.8.0 → 6.0.x-dev2020-09-13

v6.0.0 → 7.0.x-dev2020-09-13

v7.0.0 → v8.0.02020-09-29

PHP version history (5 changes)v5.3.0PHP &gt;=5.6.4

5.5.x-devPHP &gt;=7.0.0

5.6.x-devPHP &gt;=7.1.3

6.0.x-devPHP ^7.2

7.0.x-devPHP ^7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4564469?v=4)[Sociata](/maintainers/Vinelab)[@Vinelab](https://github.com/Vinelab)

---

Top Contributors

[![Mulkave](https://avatars.githubusercontent.com/u/2647333?v=4)](https://github.com/Mulkave "Mulkave (20 commits)")[![harris21](https://avatars.githubusercontent.com/u/1542015?v=4)](https://github.com/harris21 "harris21 (16 commits)")[![adiachenko](https://avatars.githubusercontent.com/u/10194667?v=4)](https://github.com/adiachenko "adiachenko (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![speccode](https://avatars.githubusercontent.com/u/1951131?v=4)](https://github.com/speccode "speccode (1 commits)")

---

Tags

laravelmicroservicephpscalable-applicationsframeworklaravelscaffoldarchitecturemicroserviceslucid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lucid-arch-laravel-microservice/health.svg)

```
[![Health](https://phpackages.com/badges/lucid-arch-laravel-microservice/health.svg)](https://phpackages.com/packages/lucid-arch-laravel-microservice)
```

###  Alternatives

[laravel/laravel

The skeleton application for the Laravel framework.

84.6k62.4M1.0k](/packages/laravel-laravel)[unopim/unopim

UnoPim Laravel PIM

10.5k2.2k](/packages/unopim-unopim)[bagisto/bagisto

Bagisto Laravel E-Commerce

27.6k169.0k9](/packages/bagisto-bagisto)[krayin/laravel-crm

Krayin CRM

23.2k33.4k1](/packages/krayin-laravel-crm)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3911.7k](/packages/codewithdennis-larament)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
