app->singleton(ExtensionManifestValidator::class); $this->app->singleton(ExtensionAssetPublisher::class); $this->app->singleton(ExtensionSettingsRegistry::class); $this->app->singleton(ExtensionPermissionRegistry::class); $this->app->singleton(ExtensionFieldRegistry::class); $this->app->singleton(ExtensionRepository::class); $this->app->singleton(ExtensionLock::class); $this->app->singleton(ExtensionProviderLoader::class); $this->app->singleton(ExtensionActionDecorators::class); $this->app->singleton(ExtensionConsoleRegistry::class); $this->app->singleton(ExtensionHeadTags::class); $this->app->singleton(ExtensionFailureAttributor::class); // Remembers the active theme for one request or job at a time. $this->app->scoped(ThemeRepository::class); $this->app->scoped(ThemeResolver::class); if (! config('extensions.enabled')) { return; } // Registered during the provider registration phase, then executed after // the core app has booted. Application::register() immediately runs // Laravel's normal provider boot path inside the loader's failure boundary. $this->app->booted(fn () => $this->app->make(ExtensionProviderLoader::class)->registerProviders($this->app->make(ExtensionRepository::class)->enabled())); } public function boot(): void { // Root path routes of extensions are public, so they are throttled per client. RateLimiter::for('extensions.root', function (Request $request): Limit { $user = $request->user(); return Limit::perMinute(config()->integer('extensions.root_routes_per_minute')) ->by($user instanceof User ? $user->uuid : $request->ip()); }); AboutCommand::add('Extensions', fn (): array => $this->about()); if (! config('extensions.enabled')) { return; } // The console application starts after every extension provider has been // committed, so the registry only ever hands over what booted successfully. Its // commands are added by Pterodactyl\Console\Kernel once the panel's own exist; the // scheduler is wired the way core's own schedule is (bootstrap/app.php). Artisan::starting(static function (Artisan $artisan): void { $app = $artisan->getLaravel(); $registry = $app->make(ExtensionConsoleRegistry::class); $app->afterResolving(Schedule::class, static fn (Schedule $schedule) => $registry->schedule($schedule)); if ($app->resolved(Schedule::class)) { $registry->schedule($app->make(Schedule::class)); } }); Exceptions::reportable(function (Throwable $throwable): void { $this->app->make(ExtensionFailureAttributor::class)->attribute($throwable); }); } /** * The `php artisan about` rows for extensions: each installed one with its version and * state, the way Laravel packages report themselves there. * * @return array */ private function about(): array { if (! config('extensions.enabled')) { return ['Status' => 'OFF']; } $extensions = $this->app->make(ExtensionRepository::class); $records = $extensions->records(); $rows = []; foreach ($extensions->discovered() as $manifest) { $record = $records->get($manifest->id); $state = match (true) { $record === null => 'not registered', $record->error !== null => $record->enabled ? 'enabled, failing' : 'disabled, failing', $record->enabled => 'enabled', default => 'disabled', }; $rows[$manifest->id] = sprintf('%s (%s)', $manifest->version, $state); } foreach (array_keys($extensions->discoveryErrors()) as $directory) { $rows[$directory] = 'invalid manifest'; } return $rows === [] ? ['Installed' => 'none'] : $rows; } }