Skip to content

context:make Command

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

The single entry point for RawDigs scaffolding. Use it like Laravel’s native make:* generators for individual artifacts, or omit the type to scaffold an entire bundle (model, controllers, requests, policies, etc.) in one pass.


Two Modes At A Glance

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

If you skip the second argument, the command switches to bundle mode and either honours the flags you pass or opens an interactive multiselect prompt.


Single-Artifact Mode

Examples:

php artisan context:make model Track --context=Catalog --with-migration
php artisan context:make controller Track --context=Catalog --resource
php artisan context:make request Track --context=Catalog --variant=Store
php artisan context:make repository Track --context=Catalog
php artisan context:make middleware EnsureTrackPublished --context=Catalog

Supported types (aliases in parentheses):

  • model (--with-migration)
  • migration
  • controller (--resource)
  • api-controller
  • request / requests (--variant=Store|Update)
  • factory
  • policy
  • resource
  • filament-resource
  • repository
  • action
  • dto
  • contract
  • provider
  • event
  • middleware
  • observer
  • job
  • notification
  • listener
  • mail / mailable
  • rule
  • cast
  • scope
  • trait
  • enum
  • seeder
  • command
  • config
  • interface

Under the hood the command shells out to Laravel’s generators (make:model, make:controller, make:request, etc.), then relocates the resulting files into app/Contexts/{Context}/… while fixing namespaces and imports.


Bundle Mode (Multi-Scaffold)

Generate everything for a bounded context resource in a single run:

php artisan context:make Track --context=Catalog --model --migration --controller --requests --policy --resource --repository

Flags map directly to the artifacts that will be generated. If you omit them, the CLI opens an interactive prompt so you can pick what you need.

Flag Type generated Output (after relocation)
--model Model app/Contexts/{Context}/Models/{Name}.php
--migration Migration database/migrations/*create_{name}_table.php
--controller Inertia/web controller (resourceful) 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 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 binding 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 interface 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 Trait app/Contexts/{Context}/Traits/{Name}.php
--enum PHP enum app/Contexts/{Context}/Enums/{Name}.php
--seeder 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 Force overwrite Passed through to each generated artifact

The controller option automatically generates a resourceful controller; selecting the API controller adds an *ApiController alongside it. When both --model and --migration are chosen, a migration stub named create_{plural}_table is generated alongside the model.


Composer Wrapper

Composer scripts provide the same Sail-aware shortcut:

composer run context:make -- Track --context=Catalog --model --migration

Everything after -- is passed straight to the command. Use composer run context:delete -- Track --context=Catalog when you need the teardown helper.


Output Summary

Depending on what you scaffold, expect files under:

  • app/Contexts/{Context}/Models/{Name}.php
  • app/Contexts/{Context}/Http/Controllers/{Name}Controller.php
  • app/Contexts/{Context}/Http/Controllers/{Name}ApiController.php
  • app/Contexts/{Context}/Http/Requests/{Name}/{Store|Update}{Name}Request.php
  • app/Contexts/{Context}/Http/Middleware/{Name}Middleware.php
  • app/Contexts/{Context}/Http/Resources/{Name}Resource.php
  • app/Contexts/{Context}/Policies/{Name}Policy.php
  • app/Contexts/{Context}/Repositories/{Name}Repository.php
  • app/Contexts/{Context}/Actions/{Name}Action.php
  • app/Contexts/{Context}/DTOs/{Name}Data.php
  • app/Contexts/{Context}/Contracts/{Name}Contract.php
  • app/Contexts/{Context}/Providers/{Name}ServiceProvider.php
  • app/Contexts/{Context}/Events/{Name}.php
  • app/Contexts/{Context}/Observers/{Name}Observer.php
  • app/Contexts/{Context}/Jobs/{Name}.php
  • app/Contexts/{Context}/Notifications/{Name}.php
  • app/Contexts/{Context}/Listeners/{Name}.php
  • app/Contexts/{Context}/Mail/{Name}.php
  • app/Contexts/{Context}/Rules/{Name}.php
  • app/Contexts/{Context}/Casts/{Name}.php
  • app/Contexts/{Context}/Scopes/{Name}Scope.php
  • app/Contexts/{Context}/Traits/{Name}.php
  • app/Contexts/{Context}/Enums/{Name}.php
  • database/factories/{Context}/{Name}Factory.php
  • database/migrations/*create_{name_plural}_table.php
  • database/seeders/{Name}Seeder.php
  • app/Console/Commands/{Name}.php
  • config/{name_snake}.php
  • app/Contracts/{Name}.php (falls back to app/Interfaces)
  • app/Filament/Resources/{Context}/{Name}Resource.php

  • docs/cli/index.md
  • docs/commands/context-delete.md