CLI Reference

The lucid command line interface companion for the Lucid Architecture.

lucid is a set of methods to easily manage [create, delete] Lucid units such as Jobs, Operations, Features as well as Laravel’s own components such as Controller, Eloquent Model, Request and Policy; ensuring that they go where they belong and are generated with their test companion classes.


Setup

The executable binary can be found at ./vendor/bin/lucid after requiring lucid-arch/console.

For convenience you might want to address lucid directly instead of having to go through ./vendor/bin every time. To do that you need to add ./vendor/bin to your shell session’s $PATH. For the current session, run:

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

However, it will only be available for the current session. To make it permanent, add it to your shell profile (~/.bash_profile, ~/.bashrc, ~/.zshrc) and you will be able to simply call lucid from the application’s root directory.

Use list to view a list of all available commands:

lucid list

Also, just like in Artisan, every command includes a “help” screen describes the command’s available arguments and options. To view a help screen, precede the name of the command with help or use the --help option:

lucid help make:feature
# or
lucid make:feature --help

Commands

make:service

 For Monolith projects only.

Create a new service in a monolith project.

lucid make:service <name>

# example

lucid make:service HumanResources

Will generate the following structure:

src
└── Services
    └── HumanResources
        ├── Providers
        ├── Console
        ├── Http
        ├── Features
        ├── Operations
        ├── Tests
        ├── database
        ├── routes
        └── resources

make:controller

Generate a controller class.

Signature

lucid make:controller <controller>

Example

lucid make:controller Article

Generated class will be at app/Http/Controllers/ArticleController.php

Signature

lucid make:controller <controller> <service>

Example

lucid make:controller Article Publishing

Generated class will be at app/Services/Publishing/Http/Controllers/ArticleController.php

Empty Controller

By default it will generate an empty controller. To generate a resource controller use the --resource option:

lucid make:controller <controller> [<service>] --resource

make:feature

Generate a Feature class.

Signature

 lucid make:feature <feature>

Example

 lucid make:feature ListProducts

Generated class will be at app/Features/ListProductsFeatures.php

and its test at tests/Feature/ListProductsFeaturesTest.php

Signature

 lucid make:feature <feature> <service>

Example

 lucid make:feature ListProducts Commerce

Generated class will be at app/Services/Commerce/Features/ListProductsFeatures.php

and its test at tests/Feature/Services/Commerce/ListProductsFeaturesTest.php

The generated Feature class will automatically be suffixed with Feature, so there’s no need for it to be specified in the command.


make:job

Generate a Job class.

Signature

 lucid make:job <job> <domain> {--Q|queue}

Example

 lucid make:job FindProduct product

Generated class will be at app/Domains/Product/Jobs/FindProductJob.php

and its test at tests/Unit/Domains/Product/Jobs/FindProductJobTest.php

Signature

 lucid make:job <job> <domain> {--Q|queue}

Example

 lucid make:job FindProduct product

Generated class will be at app/Domains/Product/Jobs/FindProductJob.php

and its test at tests/Unit/Domains/Product/Jobs/FindProductJobTest.php

The generated Job class will automatically be suffixed with Job, so there’s no need for it to be specified in the command.


make:operation

Signature

lucid make:operation <operation> {--Q|queue}

Example

lucid make:operation NotifySubscribers

Generated class will be at app/Operations/NotifySubscribersOperation.php

and its test at tests/Unit/Operations/NotifySubscribersOperationTest.php

Signature

lucid make:operation <operation> <service> {--Q|queue}

Example

lucid make:operation NotifySubscribers publishing

Generated class will be at app/Services/Publishing/Operations/NotifySubscribersOperation.php

and its test at tests/Unit/Services/Publishing/Operations/NotifySubscribersOperationTest.php

The generated Operation class will automatically be suffixed with Operation, so there’s no need for it to be specified in the command.


make:migration

Signature

lucid make:migration <migration>

Example

lucid make:migration create_articles_table

Generated file will be at database/migrations/2020_10_28_180253_create_articles_table.php

Signature

lucid make:migration <migration> <service>

Example

lucid make:migration create_articles_table publishing

Generated file will be at app/Services/Publishing/database/migrations/2020_10_28_180253_create_articles_table.php


make:model

Generate an Eloquent model class.

Signature

lucid make:model <name>

Example

lucid make:model Product

Generated model file will be at app/Data/Product.php.


make:request

lucid make:request <request> <domain>

Generated file will be at app/Domains/<domain>/Requests/<request>.

lucid make:request <request> <domain>

Generated file will be at app/Domains/<domain>/Requests/<request>.


make:policy

lucid make:policy <policy>

Generated file will be at app/Http/Policies/<policy>.

lucid make:policy <policy> <service>

Generated file will be at app/Services/<service>/Http/Policies/<policy>.


list:services

List the services in a monolith project

 For Monolith projects only.

lucid list:services
+------------+------------+-------------------------+
| Service    | Slug       | Path                    |
+------------+------------+-------------------------+
| Commerce   | commerce   | app/Services/Commerce   |
| Publishing | publishing | app/Services/Publishing |
| Admin      | admin      | app/Services/Admin      |
+------------+------------+-------------------------+

list:features

lucid list:features

delete:service

 For Monolith projects only.

lucid delete service <name>

delete:feature

lucid delete:feature <feature> [<service>]

delete:job

lucid delete:job <job> <domain>

delete:model

delete:model <model>

delete:request

lucid delete:request <request> [<service>]

delete:policy

delete:policy <policy> [<service>]