rahasistiyak/laravel-super-artisan
Installation:
composer require rahasistiyak/laravel-super-artisan
php artisan vendor:publish --tag=super-artisan-config
php artisan vendor:publish --tag=super-artisan-stubs
config/super-artisan.php and stubs are published.First Command:
Generate a basic MVC structure (model + controller + migration) for a Post resource:
php artisan make:super Post
app/Models/, app/Http/Controllers/, database/migrations/).Where to Look First:
config/super-artisan.php – Customize paths, patterns, and defaults.resources/stubs/super-artisan/ – Modify templates for generated files (e.g., model.stub, controller.stub).config/super-artisan.php under workflows – Predefined command sequences.php artisan make:super Post --mvc
Generates: Model, Controller, Migration, and optionally a Blade/Livewire/React/Vue view.php artisan make:super Post --repository
Generates: Model, Repository Interface, Repository Class, and Service binding in AppServiceProvider.php artisan make:super Post --service
Generates: Model, Service Class, and binds it in AppServiceProvider.Override default paths via CLI or config:
php artisan make:super Post --model-path="Modules/Posts/Models" --controller-path="Modules/Posts/Http/Controllers"
Or update config/super-artisan.php:
'paths' => [
'models' => 'Modules/{name}/Models',
'controllers' => 'Modules/{name}/Http/Controllers',
],
Generate Livewire, Vue, or React components alongside backend logic:
php artisan make:super Post --livewire
# or
php artisan make:super Post --vue --component-name="PostComponent"
Execute predefined sequences (e.g., deployment):
php artisan run:workflow deploy
Customize workflows in config/super-artisan.php:
'workflows' => [
'deploy' => [
'migrate',
'optimize:clear',
'queue:work',
],
],
Extend the package by defining new blueprints (e.g., for API resources):
php artisan make:super Post --blueprint="api"
Define blueprints in config/super-artisan.php under blueprints.
Stub Customization:
resources/stubs/super-artisan/ to match your project’s coding standards.controller.stub to include custom middleware or traits.Event Listeners:
Trigger actions post-generation via SuperArtisanGenerated event:
// In EventServiceProvider
protected $listen = [
\Rahasistiyak\SuperArtisan\Events\SuperArtisanGenerated::class => [
\App\Listeners\PostGenerationListener::class,
],
];
Testing: Use the package in feature tests to assert file generation:
$this->artisan('make:super TestModel')
->assertExitCode(0)
->expectsOutput('Model created successfully!');
CI/CD Pipelines: Automate workflows in GitHub Actions or GitLab CI:
# .github/workflows/deploy.yml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- run: php artisan run:workflow deploy
Stub File Conflicts:
{name}, {table}).php artisan vendor:publish --tag=super-artisan-stubs --force to reset stubs.Path Resolution Issues:
{name} placeholders must match the generated class name.config/super-artisan.php path syntax.Workflows Not Triggering:
migrate is a core command).config/super-artisan.php for typos or unsupported commands.Namespace Collisions:
App\) may cause conflicts.--model-namespace="Modules\Posts").Livewire/Vue/React Dependencies:
composer require livewire/livewire
npm install vue@next react
Verbose Output:
Enable debug mode in config/super-artisan.php:
'debug' => true,
Re-run commands to see detailed file operations.
Log Generation:
Check Laravel logs (storage/logs/laravel.log) for errors during generation.
Dry Runs: Test workflows locally before deploying:
php artisan run:workflow deploy --dry-run
Alias Commands:
Add shortcuts to app/Console/Kernel.php:
protected $commands = [
\Rahasistiyak\SuperArtisan\Console\MakeSuperCommand::class => 'make:super',
\Rahasistiyak\SuperArtisan\Console\RunWorkflowCommand::class => 'run:wf',
];
Now use:
php artisan run:wf deploy
Partial Generation: Skip specific files (e.g., no migration):
php artisan make:super Post --skip-migration
Blueprints for Teams: Share custom blueprints across projects by publishing them to a private Composer package.
Post-Generation Hooks:
Use the SuperArtisanGenerated event to auto-run tests, seeders, or notifications:
// In PostGenerationListener
public function handle(SuperArtisanGenerated $event) {
if ($event->blueprint === 'api') {
Artisan::call('test:run', ['--filter' => 'Feature\Api\Posts']);
}
}
Performance: For large-scale generation (e.g., 100+ files), batch commands to avoid memory issues:
php artisan make:super Post1 --quiet
php artisan make:super Post2 --quiet
# ...
How can I help you explore Laravel packages today?