1pilotapp/symfony-client
1Pilot Symfony Client integrates your Symfony app with the 1Pilot dashboard for centralized monitoring and management. Track uptime and SSL, detect config and server changes, manage Composer packages, and receive alerts via email, Slack, or Discord.
Install the Package:
composer require 1pilotapp/symfony-client:^2.0
Note: While this package targets Symfony, Laravel can leverage it via Symfony’s HTTP client or by treating it as a monitoring agent.
Configure Environment:
Add to .env:
ONE_PILOT_PRIVATE_KEY=your_random_alphanumeric_key # Generate via 1Pilot dashboard
ONE_PILOT_MAIL_FROM_ADDRESS=no-reply@yourdomain.com # Must match your app’s mail sender
Add Configuration:
Create config/one_pilot.php (Laravel-style):
return [
'private_key' => env('ONE_PILOT_PRIVATE_KEY'),
'mail_from_address' => env('ONE_PILOT_MAIL_FROM_ADDRESS'),
'skip_timestamp_validation' => env('ONE_PILOT_SKIP_TIMESTAMP', false), // For dev only
];
Register Routes:
Add to routes/web.php (or routes/api.php):
Route::prefix('/1pilot')->group(function () {
\OnePilot\ClientBundle\DependencyInjection\OnePilotClientExtension::loadRoutes();
});
First Use Case:
Monitoring Agent Integration:
/1pilot/health endpoint. Call it periodically from Laravel’s scheduler:
// app/Console/Kernel.php
protected function schedule(Schedule $schedule) {
$schedule->call(function () {
Http::get('https://your-app.com/1pilot/health');
})->everyMinute();
}
events:
// app/Providers/EventServiceProvider.php
public function boot() {
event(new \OnePilot\ClientBundle\Event\CustomMetricEvent(
'laravel_custom_metric',
['value' => app()->version()]
));
}
Email Verification:
// In a mailable or controller
Mail::to('user@example.com')->send(new VerificationEmail());
// 1Pilot will auto-detect and log the email.
Composer Updates:
composer.json events:
// app/Providers/AppServiceProvider.php
public function boot() {
Composer::updating(function ($event) {
\OnePilot\ClientBundle\Composer\ComposerUpdater::sync($event->getLock());
});
}
Service Container Binding: Bind the 1Pilot client to Laravel’s container for DI:
// app/Providers/AppServiceProvider.php
public function register() {
$this->app->singleton(\OnePilot\ClientBundle\Client::class, function ($app) {
return new \OnePilot\ClientBundle\Client(
$app['config']['one_pilot.private_key'],
$app['config']['one_pilot.mail_from_address']
);
});
}
Middleware for API Calls: Add 1Pilot headers to outgoing API requests:
// app/Http/Middleware/Add1PilotHeaders.php
public function handle($request, Closure $next) {
$response = $next($request);
$response->headers->set('X-1Pilot-Site-ID', config('one_pilot.site_id'));
return $response;
}
Artisan Commands: Create a command to manually trigger syncs:
// app/Console/Commands/Sync1Pilot.php
public function handle() {
$client = app(\OnePilot\ClientBundle\Client::class);
$client->syncAll();
$this->info('Synced with 1Pilot!');
}
Private Key Mismatch:
.env. Ensure the key is exactly the same (case-sensitive).Time Synchronization Issues:
ntpdate pool.ntp.org), orskip_timestamp_validation: true in config (dev only).Email Verification Failures:
ONE_PILOT_MAIL_FROM_ADDRESS matches the From address in your Laravel mailer.Mail::raw('Test email for 1Pilot', function ($message) {
$message->to('user@example.com')->from(config('one_pilot.mail_from_address'));
});
Route Conflicts:
/1pilot/* endpoints.routes/web.php:
Route::prefix('/1pilot')->group(function () {
\OnePilot\ClientBundle\DependencyInjection\OnePilotClientExtension::loadRoutes();
});
Route::get('/', function () { ... }); // Other routes
Composer Lock File Sync:
composer update:
php artisan sync:1pilot
Enable Verbose Logging:
Add to config/one_pilot.php:
'debug' => env('APP_DEBUG', false),
Check Laravel logs (storage/logs/laravel.log) for 1Pilot-related errors.
API Request Inspection:
Use Laravel’s Http facade to inspect 1Pilot API calls:
$response = Http::withHeaders([
'Authorization' => 'Bearer ' . config('one_pilot.private_key'),
])->get('https://api.1pilot.io/v1/site/verify');
Disable Features Temporarily:
Override config in bootstrap/app.php:
$app->configure('one_pilot', function ($config) {
$config['skip_timestamp_validation'] = true;
$config['disable_composer_sync'] = true;
});
Custom Events:
Extend the CustomMetricEvent to send Laravel-specific metrics:
// app/Events/Custom1PilotMetric.php
class Custom1PilotMetric implements ShouldBroadcast {
public function __construct(
public string $name,
public array $data,
public ?int $siteId = null
) {}
}
Webhook Listeners: Listen for 1Pilot webhooks (e.g., downtime alerts) in Laravel:
// routes/web.php
Route::post('/1pilot/webhook', [WebhookController::class, 'handle']);
Database Sync: Sync Laravel’s database schema changes to 1Pilot:
// app/Providers/AppServiceProvider.php
public function boot() {
Schema::defaultStringLength(191);
\OnePilot\ClientBundle\Database\DatabaseSync::syncSchema();
}
// app/Console/Kernel.php
$schedule->command('sync:1pilot')->hourlyAt(30);
$client->syncComposerPackages(array_slice($packages, 0, 50));
How can I help you explore Laravel packages today?