Skip to content

Artisan Commands

Jean-Marc Strauven edited this page Aug 6, 2025 · 2 revisions

πŸ”§ Artisan Commands

← Queue Integration | Home | Configuration β†’

Laravel Flowpipe provides powerful Artisan commands for managing, debugging, and executing workflows from the command line.

πŸ“‹ Available Commands

Core Commands

# List all available flows
php artisan flowpipe:list

# Run a specific flow
php artisan flowpipe:run flow-name

# Validate flow definitions
php artisan flowpipe:validate

# Show detailed flow information
php artisan flowpipe:show flow-name

# Generate step class
php artisan flowpipe:make:step StepName

# Generate flow YAML template
php artisan flowpipe:make:flow flow-name

πŸš€ Running Flows

Basic Execution

# Run with default data from YAML
php artisan flowpipe:run user-registration

# Run with custom data (JSON)
php artisan flowpipe:run user-registration '{"name":"John","email":"[email protected]"}'

# Run with data from file
php artisan flowpipe:run user-registration --data=/path/to/data.json

# Run with verbose output
php artisan flowpipe:run user-registration --verbose

# Run with tracing enabled
php artisan flowpipe:run user-registration --trace

Advanced Execution Options

# Run specific steps only
php artisan flowpipe:run user-registration --steps=validate-input,create-user

# Skip specific steps
php artisan flowpipe:run user-registration --skip=send-welcome-email

# Run with timeout
php artisan flowpipe:run user-registration --timeout=300

# Run asynchronously (queue)
php artisan flowpipe:run user-registration --async

# Run with custom configuration
php artisan flowpipe:run user-registration --config='{"retry_attempts":5}'

πŸ“Š Flow Management

Listing Flows

# List all flows
php artisan flowpipe:list

# List flows with details
php artisan flowpipe:list --detailed

# Filter flows by tag
php artisan flowpipe:list --tag=user

# Show flows in specific directory
php artisan flowpipe:list --path=flows/user

# Export flow list to JSON
php artisan flowpipe:list --format=json > flows.json

Output example:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Flow Name               β”‚ Description                     β”‚ Version β”‚ Tags             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ user-registration       β”‚ Complete user registration     β”‚ 2.1     β”‚ user, auth       β”‚
β”‚ order-processing        β”‚ E-commerce order processing     β”‚ 1.5     β”‚ ecommerce, order β”‚
β”‚ content-moderation      β”‚ Automated content review        β”‚ 1.0     β”‚ content, ai      β”‚
β”‚ newsletter-campaign     β”‚ Email campaign with segments    β”‚ 1.2     β”‚ email, marketing β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Flow Information

# Show detailed flow information
php artisan flowpipe:show user-registration

# Show flow steps only
php artisan flowpipe:show user-registration --steps

# Show flow dependencies
php artisan flowpipe:show user-registration --dependencies

# Export flow definition
php artisan flowpipe:show user-registration --export=json > user-registration.json

βœ… Validation and Testing

Validate Flow Definitions

# Validate all flows
php artisan flowpipe:validate

# Validate specific flow
php artisan flowpipe:validate user-registration

# Validate with strict mode (warnings as errors)
php artisan flowpipe:validate --strict

# Validate and show detailed errors
php artisan flowpipe:validate --verbose

# Validate flows in specific directory
php artisan flowpipe:validate --path=flows/production

Dry Run Testing

# Dry run without executing steps
php artisan flowpipe:run user-registration --dry-run

# Test with mock data
php artisan flowpipe:test user-registration

# Test all flows
php artisan flowpipe:test:all

# Generate test report
php artisan flowpipe:test user-registration --report=/tmp/test-report.html

πŸ—οΈ Code Generation

Generate Step Classes

# Basic step class
php artisan flowpipe:make:step ValidateUserStep

# Step with namespace
php artisan flowpipe:make:step User/ValidateUserStep

# Step with template
php artisan flowpipe:make:step ProcessPaymentStep --template=payment

# Step with full setup
php artisan flowpipe:make:step CreateUserStep --with-test --with-contract

Generated step example:

<?php

namespace App\Flowpipe\Steps;

use Closure;
use Grazulex\LaravelFlowpipe\Contracts\FlowStep;

class ValidateUserStep implements FlowStep
{
    public function handle(mixed $payload, Closure $next): mixed
    {
        // TODO: Implement step logic
        
        return $next($payload);
    }
}

Generate Flow Templates

# Basic flow template
php artisan flowpipe:make:flow user-onboarding

# Flow with steps
php artisan flowpipe:make:flow order-processing --steps=validate,process,fulfill

# Flow from template
php artisan flowpipe:make:flow newsletter --template=email-campaign

# Interactive flow builder
php artisan flowpipe:make:flow --interactive

πŸ” Debugging and Monitoring

Flow Tracing

# Run with detailed tracing
php artisan flowpipe:run user-registration --trace

# Export trace to file
php artisan flowpipe:run user-registration --trace --trace-file=/tmp/trace.json

# Trace specific steps
php artisan flowpipe:run user-registration --trace --trace-steps=validate-input,create-user

# Live trace monitoring
php artisan flowpipe:trace user-registration --follow

Performance Analysis

# Analyze flow performance
php artisan flowpipe:analyze user-registration

# Performance report for all flows
php artisan flowpipe:analyze --all

# Compare flow performance
php artisan flowpipe:compare user-registration-v1 user-registration-v2

# Generate performance report
php artisan flowpipe:performance-report --format=html > performance.html

Queue Management

# Show queued flows
php artisan flowpipe:queue:status

# Retry failed flows
php artisan flowpipe:queue:retry

# Clear failed flows
php artisan flowpipe:queue:clear-failed

# Monitor queue in real-time
php artisan flowpipe:queue:monitor

πŸ”§ Configuration Management

Configuration Commands

# Show current configuration
php artisan flowpipe:config

# Validate configuration
php artisan flowpipe:config:validate

# Export configuration
php artisan flowpipe:config:export > flowpipe-config.json

# Reset configuration to defaults
php artisan flowpipe:config:reset

Environment Management

# Set environment-specific flows
php artisan flowpipe:env:set production

# List environment configurations
php artisan flowpipe:env:list

# Sync flows between environments
php artisan flowpipe:env:sync staging production

πŸ“Š Real-World Usage Examples

Development Workflow

# 1. Create a new flow
php artisan flowpipe:make:flow user-verification --interactive

# 2. Generate required steps
php artisan flowpipe:make:step SendVerificationEmailStep
php artisan flowpipe:make:step VerifyEmailTokenStep

# 3. Validate the flow
php artisan flowpipe:validate user-verification

# 4. Test with sample data
php artisan flowpipe:run user-verification --dry-run

# 5. Run with real data
php artisan flowpipe:run user-verification '{"user_id":123,"email":"[email protected]"}'

Production Deployment

# 1. Validate all flows before deployment
php artisan flowpipe:validate --strict

# 2. Run health checks
php artisan flowpipe:health-check

# 3. Test critical flows
php artisan flowpipe:test:critical

# 4. Monitor deployment
php artisan flowpipe:monitor --env=production

Debugging Issues

# 1. Identify the failing flow
php artisan flowpipe:queue:status

# 2. Run with detailed tracing
php artisan flowpipe:run problematic-flow --trace --verbose

# 3. Analyze the trace
php artisan flowpipe:trace:analyze /tmp/trace.json

# 4. Test fix with dry run
php artisan flowpipe:run problematic-flow --dry-run

πŸ”„ Batch Operations

Bulk Flow Management

# Run multiple flows
php artisan flowpipe:batch:run user-registration,order-processing,content-moderation

# Run flows matching pattern
php artisan flowpipe:batch:run "user-*"

# Run flows by tag
php artisan flowpipe:batch:run --tag=critical

# Parallel execution
php artisan flowpipe:batch:run --parallel --workers=4 user-registration order-processing

# With custom data for each flow
php artisan flowpipe:batch:run --data-file=batch-data.json

Data Processing

# Process CSV data through flow
php artisan flowpipe:process:csv user-registration users.csv

# Process JSON file
php artisan flowpipe:process:json order-processing orders.json

# Process with custom mapping
php artisan flowpipe:process:csv user-registration users.csv --mapping=mapping.json

# Chunked processing for large files
php artisan flowpipe:process:csv user-registration large-users.csv --chunk=1000

πŸ§ͺ Testing Integration

Automated Testing

# Run flow test suite
php artisan flowpipe:test:suite

# Run specific test categories
php artisan flowpipe:test:suite --category=critical

# Generate test coverage report
php artisan flowpipe:test:coverage

# Run performance benchmarks
php artisan flowpipe:benchmark

Load Testing

# Simulate load on specific flow
php artisan flowpipe:load:test user-registration --concurrent=10 --duration=60

# Stress test with increasing load
php artisan flowpipe:load:stress user-registration --start=1 --end=50 --step=5

# Generate load test report
php artisan flowpipe:load:report > load-test-results.html

πŸ’‘ Custom Commands

Creating Custom Commands

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Grazulex\LaravelFlowpipe\Flowpipe;

class ProcessDailyReportsCommand extends Command
{
    protected $signature = 'flowpipe:daily-reports {date?}';
    
    protected $description = 'Process daily reports using Flowpipe';

    public function handle()
    {
        $date = $this->argument('date') ?? now()->subDay()->toDateString();
        
        $this->info("Processing daily reports for {$date}");
        
        $result = Flowpipe::fromYaml('daily-analytics-report')
            ->send(['date' => $date])
            ->execute();
            
        if ($result->isSuccessful()) {
            $this->info('Daily reports processed successfully');
        } else {
            $this->error('Failed to process daily reports: ' . $result->error->getMessage());
        }
    }
}

Integration with Laravel Scheduler

// In app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
    // Daily reports
    $schedule->command('flowpipe:daily-reports')
        ->daily()
        ->at('01:00');
        
    // Weekly cleanup
    $schedule->command('flowpipe:run weekly-cleanup')
        ->weekly()
        ->sundays()
        ->at('02:00');
        
    // Health checks
    $schedule->command('flowpipe:health-check')
        ->everyFifteenMinutes();
}

πŸ“‹ Command Reference

Command Description Options
flowpipe:list List all available flows --detailed, --tag, --format
flowpipe:run Execute a flow --data, --trace, --async, --timeout
flowpipe:show Show flow details --steps, --dependencies, --export
flowpipe:validate Validate flow definitions --strict, --path
flowpipe:make:step Generate step class --template, --with-test
flowpipe:make:flow Generate flow template --steps, --template, --interactive
flowpipe:trace Trace flow execution --follow, --steps
flowpipe:queue:status Show queue status --queue, --connection
flowpipe:test Test flow execution --dry-run, --report
flowpipe:analyze Analyze flow performance --all, --format

🎯 What's Next?

πŸš€ Laravel Flowpipe

🏠 Home

🏁 Getting Started

πŸ“š Core Concepts

πŸš€ Advanced Features

πŸ› οΈ Tools & Configuration

πŸ“– Examples


πŸ”— GitHub Repository

Clone this wiki locally