ajaykushwaha25/custom-make-command
Laravel dev package adding custom Artisan generators: make:trait plus custom:class, custom:action, and custom:service to scaffold files under App (and subfolders). Also includes a UsesUUID trait to add UUID IDs to Eloquent models.
make: commands (e.g., make:controller, make:model, etc.) with predefined templates or configurations. It fits well in projects requiring standardized scaffolding (e.g., monorepos, design systems, or teams enforcing boilerplate patterns).make:api-resource, make:job-with-retry).resources/stubs/ (or configurable path).Artisan::call().assertFileExists(), assertStringContainsFile()).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Stub Version Drift | High | Pin stubs to commits; automate updates via CI. |
| Command Naming Clashes | Medium | Prefix commands (e.g., make:myapp-controller). |
| Laravel Major Upgrades | Medium | Test against new Laravel versions early. |
| Custom Logic Errors | Low | Use php artisan make:command for complex logic. |
make: commands + IDE templates suffice?make: usage (php artisan list --format=table | grep make).make:api-controller).resources/stubs/custom/ and update composer.json:
"extra": {
"laravel": {
"stubs": "resources/stubs/custom"
}
}
CONTRIBUTING.md with stub update guidelines.php artisan make:custom-command --help.laravel/framework version constraints in composer.json.barryvdh/laravel-ide-helper).php artisan make:model TestModel && git diff --exit-code).make:api-resource, make:job).aliases in .bashrc/.zshrc:
alias makec="php artisan make:custom-command"
make:feature-test), migrations, or policies.make:controller --with-validation).git diff to track stub modifications; automate updates with a script:
# Example: Sync stubs from a shared repo
git submodule update --init --recursive
// DEPRECATED: Use make:api-resource instead).make: workflows.```bash
# Generate an API resource with FormRequest validation
php artisan make:api-resource Post --with-validation
extra.laravel.stubs path in composer.json.storage/ is writable (chmod -R 775 storage).--verbose to commands or log stub paths:
// In CustomMakeCommand.php
$this->info("Using stub: " . $this->getStubPath());
make:model User Post --parallel).replace() in stubs for dynamic values:
{% for trait in traits %}
use {{ trait }};
{% endfor %}
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Stub Corruption | Broken scaffolding | Version stubs with Git; use git checkout to restore. |
| Command Overwrite | Lost custom logic | Prefix commands (e.g., make:myapp-*). |
| Laravel Update Breaks Stubs | Generated code fails | Test against RC versions; use laravel-upgrade tool. |
| Team Ignores CLI | Inconsistent code | Enforce via PR checks (e.g., "All new controllers must use make:api-controller"). |
php artisan make:command as a template).Artisan::call() logs or Git stats (e.g., "How many make:api-resource commands ran thisHow can I help you explore Laravel packages today?