Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Make Commands Laravel Package

xammie/make-commands

xammie/make-commands adds extra Artisan generators to Laravel so you can scaffold common PHP classes—actions, services, DTOs, and more—with customizable stubs. It keeps new files consistent and saves boilerplate typing during development.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install as a dev dependency: composer require xammie/make-commands --dev. This is a code-generation tool — it has no runtime role in production.
  • Publish the config: php artisan vendor:publish --tag=make-commands-config, which gives you config/make.php. Publish the stubs too (--tag=make-commands-stubs) so you own the templates rather than reaching into vendor/.
  • config/make.php is the whole API surface: each entry registers an Artisan command name and maps it to a stub file, a target namespace, and a target path. Read that file first, then skim vendor/xammie/make-commands/src for the base generator class to see which placeholders ({{ class }}, {{ namespace }}, {{ rootNamespace }}, etc.) get substituted and which flags (--force) are inherited from Laravel's GeneratorCommand.
  • First use case: define make:action pointing at App\Actions / app/Actions with an action.stub, run php artisan make:action CreateOrder, and confirm the generated class has the right namespace, imports, and parent. If it does, you have a repeatable template for every other artifact type in your app.
  • Version note: v0.5.0 adds Laravel 10 support and is additive — no deprecations or breaking changes are listed. If you were pinned to ^0.4, that constraint will block installation on Laravel 10 projects; bump to ^0.5. Laravel 10 requires PHP 8.1+, so confirm your CI matrix.

Implementation Patterns

  • One command per artifact type. Actions, Services, DTOs, Value Objects, Query/Filter objects, Contracts, Traits, and module-level scaffolding each get their own entry. Consistent names (make:action, make:service) keep them discoverable under php artisan list make.
  • Stubs in the repo, not in vendor. Publish, then edit and commit stubs/*.stub. This is the highest-leverage move: it turns the package into your team's boilerplate standard, and stub diffs show up in code review like any other change.
  • Per-module namespaces. Duplicate an entry with a different namespace/path (e.g. make:billing-action → app/Modules/Billing/Actions) when you run a modular monolith, instead of hand-editing namespaces after generation.
  • Compose generators. Wrap several make:* calls in a single custom Artisan command (make:feature) to scaffold a vertical slice — action + DTO + test — in one shot. This is where day-to-day time savings actually compound.
  • Test the config, not just the output. A Pest/PHPUnit test using $this->artisan('make:action', ['name' => 'Foo'])->assertSuccessful() plus assertFileExists() catches broken stubs after a refactor. Iterate over every entry in config('make.commands') so a new addition is automatically covered.
  • Pair with a formatter. The generator does not run Pint. Add vendor/bin/pint --dirty to a pre-commit hook or a composer generate script so generated files land already conforming to style.
  • Keep generated paths in static analysis (PHPStan/Psalm paths) or generate into a temp dir in tests so fixtures never pollute your analysis baseline.

Gotchas and Tips

  • Config cache. After adding or editing a command in config/make.php, run php artisan config:clear. A cached config silently ignores new entries, which reads as "the package is broken."
  • Command name collisions. Entries are registered as Artisan commands; naming one make:controller or make:model shadows Laravel's built-in. Always verify with php artisan list make after adding an entry.
  • Placeholder typos fail silently. An unrecognized placeholder renders literally into the generated file. After editing a stub, generate once and grep the output for {{.
  • Namespace and path must agree. They are configured independently; a mismatch produces a file in the wrong directory with a wrong namespace and no error. A cheap assertion in your generator test (class_exists after require) catches this.
  • Trailing slashes on the configured path yield doubled separators — harmless at runtime but breaks strict assertFileExists/path assertions in tests.
  • --force overwrites without prompting. Fine interactively, dangerous in wrapper commands and CI. Never expose it unguarded in a make:feature composite.
  • Dev-only lifecycle. With composer install --no-dev the package disappears but previously discovered manifest entries can linger; run php artisan package:discover when switching between dev and prod installs. Don't reference package classes at runtime (e.g. unconditionally in a service provider) or production boots will fail.
  • 0.x semver. Minor bumps can break. Pin ^0.5, and read release notes on each bump — v0.5.0 itself is a compatible Laravel 10 addition, but the 0.x line offers no formal BC guarantee.
  • Extension points. Subclass the package's base make command to add custom flags or override buildClass() / getReplacements() — that is the standard hook for injecting imports, interfaces, or attributes into generated classes. Prefer this over string-hacking the config.
  • Debugging a failed generation. Run with -vvv; a missing or unreadable stub usually surfaces as a bare file_get_contents error with no path context, so check the resolved stub path against the published location first.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names