addDefinitions([ Client::class => function () { return new Client([ 'headers' => [ 'Accept' => 'application/json', 'User-Agent' => 'Slim-Weather/1.0', ], ]); }, OpenWeatherClient::class => function (ContainerInterface $c) { $apiKey = $_ENV['OPENWEATHER_API_KEY'] ?? $_SERVER['OPENWEATHER_API_KEY'] ?? ''; $baseUrl = 'https://api.openweathermap.org/data/3.0'; if ($apiKey === '') { throw new \RuntimeException('OPENWEATHER_API_KEY is not configured'); } return new OpenWeatherClient($c->get(Client::class), $apiKey, $baseUrl); }, ]); } public static function routes(App $app): void { // Expose a ready-to-use endpoint for consumers (optional) $app->get('/weather', GetWeatherAction::class); } }