getContainer(); // Config. $container['config'] = ConfigFactory::create($container); // Locales. $container['locale'] = LocaleManagerFactory::create(); // Smarty. $container['view'] = ViewFactory::create($container); // Logger. $container['logger'] = LoggerFactory::create($container); // Middlewares. $app->add(new LocaleMiddleware($container)); $app->add(new RouterPathMiddleware($container)); $app->add(new CspMiddleware($container)); $app->add(new LinkHeaderMiddleware($container)); // Controllers. $frontController = new FrontController($container); $jsonController = new JsonController($container); $downloadController = new DownloadController($container); // Error handling. $container['errorHandler'] = [$frontController, 'error']; $container['phpErrorHandler'] = [$frontController, 'error']; $container['notFoundHandler'] = [$frontController, 'notFound']; $container['notAllowedHandler'] = [$frontController, 'notAllowed']; // Routes. $app->get( '/', [$frontController, 'index'] )->setName('index'); $app->get( '/extractors', [$frontController, 'extractors'] )->setName('extractors'); $app->any( '/info', [$frontController, 'info'] )->setName('info'); $app->any( '/watch', [$frontController, 'info'] ); $app->any( '/download', [$downloadController, 'download'] )->setName('download'); $app->get( '/locale/{locale}', [$frontController, 'locale'] )->setName('locale'); $app->get( '/json', [$jsonController, 'json'] )->setName('json'); $app->run(); } catch (Throwable $e) { ErrorHandler::handle($e); }