Build Reactive Signals for Bluesky's AT Protocol Firehose in Laravel
at dev 2.1 kB view raw
1<?php 2 3namespace SocialDept\AtpSignals\Commands; 4 5use Illuminate\Console\Command; 6 7class InstallCommand extends Command 8{ 9 protected $signature = 'signal:install'; 10 11 protected $description = 'Install the Signal package (publish config, migrations, and run migrations)'; 12 13 public function handle(): int 14 { 15 $this->info('Installing Signal package...'); 16 $this->newLine(); 17 18 $this->publishConfiguration(); 19 $this->publishMigrations(); 20 $this->runMigrations(); 21 22 $this->displaySuccessMessage(); 23 $this->displayNextSteps(); 24 25 return self::SUCCESS; 26 } 27 28 private function publishConfiguration(): void 29 { 30 $this->comment('Publishing configuration...'); 31 $this->call('vendor:publish', [ 32 '--tag' => 'signal-config', 33 ]); 34 $this->info('✓ Configuration published'); 35 } 36 37 private function publishMigrations(): void 38 { 39 $this->comment('Publishing migrations...'); 40 $this->call('vendor:publish', [ 41 '--tag' => 'signal-migrations', 42 ]); 43 $this->info('✓ Migrations published'); 44 } 45 46 private function runMigrations(): void 47 { 48 $this->newLine(); 49 $this->comment('Running migrations...'); 50 51 if ($this->confirm('Do you want to run the migrations now?', true)) { 52 $this->call('migrate'); 53 $this->info('✓ Migrations completed'); 54 } else { 55 $this->warn('⚠ Skipped migrations. Run "php artisan migrate" manually when ready.'); 56 } 57 } 58 59 private function displaySuccessMessage(): void 60 { 61 $this->newLine(); 62 $this->info('Signal package installed successfully!'); 63 $this->newLine(); 64 } 65 66 private function displayNextSteps(): void 67 { 68 $this->line('Next steps:'); 69 $this->line('1. Review the config file: config/signal.php'); 70 $this->line('2. Create your first signal: php artisan make:signal NewPostSignal'); 71 $this->line('3. Start consuming events: php artisan signal:consume'); 72 } 73}