Weave Code
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

Laravel Super Artisan Laravel Package

rahasistiyak/laravel-super-artisan

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation:

    composer require rahasistiyak/laravel-super-artisan
    php artisan vendor:publish --tag=super-artisan-config
    php artisan vendor:publish --tag=super-artisan-stubs
    
    • Verify config/super-artisan.php and stubs are published.
  2. First Command: Generate a basic MVC structure (model + controller + migration) for a Post resource:

    php artisan make:super Post
    
    • Files are created in default Laravel paths (app/Models/, app/Http/Controllers/, database/migrations/).
  3. Where to Look First:

    • Configuration: config/super-artisan.php – Customize paths, patterns, and defaults.
    • Stubs: resources/stubs/super-artisan/ – Modify templates for generated files (e.g., model.stub, controller.stub).
    • Workflows: config/super-artisan.php under workflows – Predefined command sequences.

Implementation Patterns

Core Workflows

1. Bulk File Generation

  • MVC Pattern (Default):
    php artisan make:super Post --mvc
    
    Generates: Model, Controller, Migration, and optionally a Blade/Livewire/React/Vue view.
  • Repository Pattern:
    php artisan make:super Post --repository
    
    Generates: Model, Repository Interface, Repository Class, and Service binding in AppServiceProvider.
  • Service Pattern:
    php artisan make:super Post --service
    
    Generates: Model, Service Class, and binds it in AppServiceProvider.

2. Custom Paths

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',
],

3. Frontend Components

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"

4. Workflows

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',
    ],
],

5. Custom Blueprints

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.


Integration Tips

  1. Stub Customization:

    • Override stubs in resources/stubs/super-artisan/ to match your project’s coding standards.
    • Example: Modify controller.stub to include custom middleware or traits.
  2. Event Listeners: Trigger actions post-generation via SuperArtisanGenerated event:

    // In EventServiceProvider
    protected $listen = [
        \Rahasistiyak\SuperArtisan\Events\SuperArtisanGenerated::class => [
            \App\Listeners\PostGenerationListener::class,
        ],
    ];
    
  3. Testing: Use the package in feature tests to assert file generation:

    $this->artisan('make:super TestModel')
         ->assertExitCode(0)
         ->expectsOutput('Model created successfully!');
    
  4. 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
    

Gotchas and Tips

Pitfalls

  1. Stub File Conflicts:

    • If stubs are manually edited, ensure they retain required placeholders (e.g., {name}, {table}).
    • Fix: Use php artisan vendor:publish --tag=super-artisan-stubs --force to reset stubs.
  2. Path Resolution Issues:

    • Custom paths with {name} placeholders must match the generated class name.
    • Fix: Use absolute paths or verify config/super-artisan.php path syntax.
  3. Workflows Not Triggering:

    • Ensure workflow commands exist in Laravel’s Artisan (e.g., migrate is a core command).
    • Fix: Check config/super-artisan.php for typos or unsupported commands.
  4. Namespace Collisions:

    • Generating files in shared namespaces (e.g., App\) may cause conflicts.
    • Fix: Use custom paths or prefixes (e.g., --model-namespace="Modules\Posts").
  5. Livewire/Vue/React Dependencies:

    • Frontend component generation assumes the respective packages are installed.
    • Fix: Install dependencies first:
      composer require livewire/livewire
      npm install vue@next react
      

Debugging

  1. Verbose Output: Enable debug mode in config/super-artisan.php:

    'debug' => true,
    

    Re-run commands to see detailed file operations.

  2. Log Generation: Check Laravel logs (storage/logs/laravel.log) for errors during generation.

  3. Dry Runs: Test workflows locally before deploying:

    php artisan run:workflow deploy --dry-run
    

Tips

  1. 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
    
  2. Partial Generation: Skip specific files (e.g., no migration):

    php artisan make:super Post --skip-migration
    
  3. Blueprints for Teams: Share custom blueprints across projects by publishing them to a private Composer package.

  4. 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']);
        }
    }
    
  5. 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
    # ...
    
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope