Skip to content

๐Ÿ›  CLI Tooling Overview

Last updated: 2025-10-09 (Europe/Paris)

RawDigs extends Laravel's Artisan commands with a context-aware scaffolding workflow. This page summarises the available tooling, where generated files live, and when to stick with the standard Laravel make:* commands.


๐Ÿ“‚ Directory Strategy

We separate shared framework concerns from bounded-context code:

  • Global layer (app/...) โ€“ authentication controllers, middleware, the Inertia shell, console kernels, and other cross-cutting infrastructure stay under Laravel's default namespaces (e.g. app/Http/Controllers/Auth, app/Http/Middleware).
  • Context layer (app/Contexts/{Context}/...) โ€“ domain assets generated via context:make live here: models, HTTP assets (controllers, requests, middleware, resources), repositories, contracts, actions, DTOs, jobs, listeners, notifications, mailers, events, and service providers.
app/
โ”œโ”€โ”€ Http/                    # Framework-wide controllers/middleware (Auth, bootstrap)
โ”œโ”€โ”€ Console/
โ”œโ”€โ”€ Models/Shared/           # Truly shared models
โ””โ”€โ”€ Contexts/
    โ”œโ”€โ”€ Accounts/
    โ”‚   โ”œโ”€โ”€ Models/
    โ”‚   โ”œโ”€โ”€ Http/Controllers/
    โ”‚   โ”œโ”€โ”€ Http/Requests/
    โ”‚   โ”œโ”€โ”€ Http/Resources/
    โ”‚   โ”œโ”€โ”€ Policies/
    โ”‚   โ”œโ”€โ”€ Repositories/
    โ”‚   โ”œโ”€โ”€ Contracts/
    โ”‚   โ”œโ”€โ”€ Actions/
    โ”‚   โ”œโ”€โ”€ DTOs/
    โ”‚   โ”œโ”€โ”€ Events/
    โ”‚   โ””โ”€โ”€ Providers/
    โ””โ”€โ”€ Creators/
        โ””โ”€โ”€ โ€ฆ (same pattern)

๐Ÿš€ context:make

Two ways to use the scaffolder:

  • Single artifact: php artisan context:make {type} {name} --context={ContextName}
  • Bundle: php artisan context:make {Name} --context={ContextName} [--model --controller --requests ...]

When you provide only the resource name, the command switches to bundle mode and honours the flags below (otherwise it opens an interactive selector).

Bundle flags:

Flag Description Output
--model Generate the model app/Contexts/{Context}/Models/{Name}.php
--migration Pair a migration with the model database/migrations/*_create_{name}_table.php
--controller Inertia/web controller app/Contexts/{Context}/Http/Controllers/{Name}Controller.php
--api API controller app/Contexts/{Context}/Http/Controllers/{Name}ApiController.php
--requests Store/Update form requests app/Contexts/{Context}/Http/Requests/{Name}/
--middleware HTTP middleware app/Contexts/{Context}/Http/Middleware/{Name}Middleware.php
--factory Eloquent factory database/factories/{Context}/{Name}Factory.php
--policy Policy tied to the model app/Contexts/{Context}/Policies/{Name}Policy.php
--resource API Resource class app/Contexts/{Context}/Http/Resources/{Name}Resource.php
--filament Filament resource app/Filament/Resources/{Context}/{Name}Resource.php
--repository Repository + contract app/Contexts/{Context}/Repositories/{Name}Repository.php
--action Action class app/Contexts/{Context}/Actions/{Name}Action.php
--dto DTO stub app/Contexts/{Context}/DTOs/{Name}Data.php
--contract Contract stub app/Contexts/{Context}/Contracts/{Name}Contract.php
--provider Context service provider app/Contexts/{Context}/Providers/{Name}ServiceProvider.php
--event Domain event app/Contexts/{Context}/Events/{Name}.php
--observer Model observer app/Contexts/{Context}/Observers/{Name}Observer.php
--job Queue job app/Contexts/{Context}/Jobs/{Name}.php
--notification Notification app/Contexts/{Context}/Notifications/{Name}.php
--listener Event listener app/Contexts/{Context}/Listeners/{Name}.php
--mail Mailable app/Contexts/{Context}/Mail/{Name}.php
--rule Validation rule app/Contexts/{Context}/Rules/{Name}.php
--cast Eloquent cast app/Contexts/{Context}/Casts/{Name}.php
--scope Query scope app/Contexts/{Context}/Scopes/{Name}Scope.php
--trait PHP trait app/Contexts/{Context}/Traits/{Name}.php
--enum PHP enum app/Contexts/{Context}/Enums/{Name}.php
--seeder Database seeder database/seeders/{Name}Seeder.php
--command Console command app/Console/Commands/{Name}.php
--config Config file config/{name_snake}.php
--interface Contract interface app/Contracts/{Name}.php (falls back to app/Interfaces)
--force Overwrite existing files Applies --force to every generated artifact

Under the hood context:make calls Laravel's make:* commands, then relocates files into app/Contexts/{Context}/โ€ฆ and rewrites namespaces/imports.

Prefer Composer? Run composer run context:make -- Track --context=Catalog --model --migration.


๐Ÿงน context:delete

php artisan context:delete {name} --context={ContextName}

Prompts for the artifacts to remove and deletes the same files created by context:make. Repository bindings in config/repository.php are cleaned up when you include the Repository option.

Composer wrapper: composer run context:delete -- Track --context=Catalog.


๐Ÿ” Standard Laravel make:*

Use the stock Artisan commands for global behaviour (app-wide middleware, queue jobs, notifications, etc.). Those files remain under the traditional namespaces and can be referenced by any context.

php artisan make:middleware EnsureUserIsSubscribed
php artisan make:job GrantWelcomeCredits

  • docs/commands/context-make.md
  • docs/commands/context-delete.md
  • docs/rawdigs-contexts.md