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

Autopilot Bundle Laravel Package

dekalee/autopilot-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation

    composer require dekalee/autopilot-bundle
    

    Add the bundle to config/bundles.php:

    return [
        // ...
        Dekalee\AutopilotBundle\DekaleeAutopilotBundle::class => ['all' => true],
    ];
    
  2. Configuration Add to .env:

    DEKALEE_AUTOPILOT_APIKEY=your_api_key_here
    

    Configure in config/packages/dekalee_autopilot.yaml (or config.yml):

    dekalee_autopilot:
        api_key: '%env(DEKALEE_AUTOPILOT_APIKEY)%'
    
  3. First Use Case Inject the AutopilotManager service into a controller or service:

    use Autopilot\AutopilotManager;
    
    public function __construct(private AutopilotManager $autopilot) {}
    
    public function triggerAutopilot()
    {
        $response = $this->autopilot->trigger('event_name', ['key' => 'value']);
        return response()->json($response);
    }
    

Implementation Patterns

Core Workflows

  1. Event Triggering Use the AutopilotManager to dispatch events to AutopilotHQ:

    $this->autopilot->trigger('user_signup', ['user_id' => 123]);
    
  2. Event Listening (Webhooks) Configure a route to handle incoming webhook events:

    Route::post('/autopilot/webhook', [AutopilotWebhookController::class, 'handle']);
    

    Implement validation and logic in the controller:

    public function handle(Request $request)
    {
        $payload = $request->json()->all();
        $this->validate($payload, ['event' => 'required', 'data' => 'required']);
    
        // Process webhook logic (e.g., update user status)
        return response()->json(['status' => 'success']);
    }
    
  3. Debugging & Monitoring Leverage the debug toolbar integration to inspect API calls:

    • Check the "Autopilot" tab in Laravel Debugbar for:
      • Triggered events
      • Response statuses
      • Payloads sent/received
  4. Service Integration Wrap Autopilot calls in a dedicated service for reusability:

    class AutopilotService {
        public function __construct(private AutopilotManager $autopilot) {}
    
        public function sendUserEmail($userId, $template)
        {
            return $this->autopilot->trigger('send_email', [
                'user_id' => $userId,
                'template' => $template,
            ]);
        }
    }
    

Gotchas and Tips

Pitfalls

  1. API Key Security

    • Never hardcode the API key in config files. Always use .env.
    • Restrict access to the webhook endpoint with middleware:
      Route::post('/autopilot/webhook')
           ->middleware('signed') // Use Laravel's signed requests
           ->controller([AutopilotWebhookController::class, 'handle']);
      
  2. Webhook Validation

    • Always validate incoming webhook payloads to prevent spoofing:
      $this->validate($request, [
          'event' => 'required|string',
          'data' => 'required|array',
          'signature' => 'required|string', // If using signed payloads
      ]);
      
  3. Rate Limiting

    • AutopilotHQ may throttle requests. Implement exponential backoff in your service layer:
      use Symfony\Component\HttpClient\RetryableHttpClient;
      
      $client = new RetryableHttpClient(
          new HttpClient(),
          [
              'max_retries' => 3,
              'delay_ms' => 100,
          ]
      );
      
  4. Debugbar Dependency

    • The debug toolbar integration requires laravel-debugbar. Install it if missing:
      composer require barryvdh/laravel-debugbar --dev
      

Tips

  1. Environment-Specific Config Override the Autopilot config per environment (e.g., config/packages/dekalee_autopilot_testing.yaml):

    dekalee_autopilot:
        api_key: '%env(DEKALEE_AUTOPILOT_TEST_APIKEY)%'
        debug: true # Enable extra logging in testing
    
  2. Event Naming Convention Use consistent event names (e.g., user.{action} like user.created, user.paid) for easier tracking in AutopilotHQ.

  3. Testing Mock the AutopilotManager in tests:

    $this->mock(AutopilotManager::class)->shouldReceive('trigger')
        ->once()
        ->with('user_signup', ['user_id' => 123])
        ->andReturn(['success' => true]);
    
  4. Extension Points

    • Custom Middleware: Add middleware to the AutopilotManager to log or transform payloads:
      $this->autopilot->getClient()->getEmitter()->addSubscriber(
          new CustomAutopilotSubscriber()
      );
      
    • Event Subscribers: Listen to Autopilot events in Laravel:
      public function subscribe(Container $container, callable $next)
      {
          $next($container);
          $this->subscribeToAutopilotEvents($container);
      }
      
      protected function subscribeToAutopilotEvents(Container $container)
      {
          $container->get('events')->listen(
              'autopilot.triggered',
              [YourListener::class, 'handle']
          );
      }
      
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
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