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 All In One Command Laravel Package

azizizaidi/laravel-all-in-one-command

Scaffold a complete Laravel feature with one artisan command. Interactively generate CRUD essentials: model, migration, factory, seeder, controllers, form requests, services (optional interface), policies, web/API routes, tests, scheduled command, and Blade views.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require azizizaidi/laravel-all-in-one-command
    

    Publish the config file (if needed):

    php artisan vendor:publish --provider="Azizizaidi\AllInOneCommand\AllInOneCommandServiceProvider"
    
  2. First Use Case: Register the command in app/Console/Kernel.php:

    protected function commands()
    {
        $this->load(__DIR__.'/../vendor/azizizaidi/laravel-all-in-one-command/src/Console');
    }
    

    Run the command:

    php artisan all:in-one
    
  3. Where to Look First:

    • Config File: config/all-in-one-command.php (if published) for customization.
    • Command Class: vendor/azizizaidi/laravel-all-in-one-command/src/Console/AllInOneCommand.php to understand core logic.
    • Documentation: Check for inline PHPDoc comments in the command class for usage hints.

Implementation Patterns

Common Workflows

  1. Customizing Command Output: Override the handle() method in a custom command extending AllInOneCommand:

    namespace App\Console\Commands;
    
    use Azizizaidi\AllInOneCommand\AllInOneCommand as BaseCommand;
    
    class CustomCommand extends BaseCommand
    {
        protected $signature = 'custom:command';
        protected $description = 'My custom command';
    
        public function handle()
        {
            $this->info('Running custom logic...');
            // Extend base functionality
            parent::handle();
        }
    }
    
  2. Integrating with Laravel Artisan Events: Listen to the command's events (e.g., all-in-one-starting, all-in-one-completed) in EventServiceProvider:

    protected $listen = [
        'all-in-one-starting' => [
            \App\Listeners\LogCommandStart::class,
        ],
    ];
    
  3. Chaining Commands: Use the --chain flag to run multiple commands sequentially:

    php artisan all:in-one --chain="migrate,optimize,queue:work"
    
  4. Dynamic Command Generation: Dynamically generate commands based on environment variables or config:

    $commands = config('all-in-one-command.dynamic_commands', []);
    foreach ($commands as $command) {
        $this->call($command);
    }
    

Integration Tips

  • Queue Integration: Use dispatch() or dispatchSync() for long-running tasks.
  • Logging: Leverage Laravel's logging facade (\Log::) for command output.
  • Testing: Mock the command in PHPUnit using Artisan::call():
    $this->artisan('all:in-one')
         ->expectsQuestion('Confirm?', 'yes')
         ->assertExitCode(0);
    

Gotchas and Tips

Pitfalls

  1. Command Signature Conflicts: Avoid naming custom commands with the same signature as Laravel's built-in commands (e.g., optimize). Use unique namespaces or prefixes.

  2. Overriding Core Logic: If extending AllInOneCommand, ensure parent::handle() is called to retain base functionality unless intentional.

  3. Environment-Specific Behavior: The package may not handle environment-specific logic out of the box. Use Laravel's config() or env() helpers to manage this:

    if (app()->environment('local')) {
        $this->call('key:generate');
    }
    
  4. Performance with Large Command Chains: Long chains of commands (e.g., migrate:fresh --seed) may time out. Use --timeout or split into smaller batches.

Debugging

  • Verbose Output: Run with -v or -vvv for detailed logs:
    php artisan all:in-one -vvv
    
  • Command Isolation: Test commands in isolation before chaining:
    php artisan migrate --pretend
    
  • Event Listeners: Use telescope:install to debug events if the package emits them.

Extension Points

  1. Custom Commands: Create a Console/Commands directory in your app and register commands in Kernel.php:

    $this->load(__DIR__.'/Commands');
    
  2. Middleware: Apply middleware to commands via the handle() method:

    public function handle()
    {
        $this->middleware(CheckEnvironment::class);
        parent::handle();
    }
    
  3. Configuration Overrides: Override defaults in config/all-in-one-command.php:

    'default_commands' => [
        'migrate',
        'optimize',
        'route:clear',
    ],
    
  4. Localization: Extend language files in resources/lang/{locale}/all-in-one-command.php for custom messages.

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