/** * Register service and controller providers * * @param Application $app */ protected function registerProviders(Application $app) { $app->register(new DoctrineServiceProvider(), ['db.options' => ['driver' => 'pdo_sqlite', 'path' => $app->basePath . '/database/app.db']]); $app->register(new TwigServiceProvider(), ['twig.path' => $app->basePath . '/resources/templates']); $app->register(new MeetupServiceProvider(), ['meetup.api_key' => getenv('MEETUP_API_KEY')]); $app->register(new ServiceControllerServiceProvider()); $app->register(new ControllersProvider()); }
/** * Application constructor. * * @todo Read version from somewhere? * * @param App $silexApp * * @return Application */ public function __construct(App $silexApp) { parent::__construct('Silex - Backend', '0.0.0'); // Store application $this->silexApp = $silexApp; // Register console application specified providers $this->silexApp->register(new DoctrineMigrationsProvider($this), $this->getDoctrineMigrationsProviderOptions()); // Register pure Doctrine commands $this->registerDoctrineCommands(); // Boot application $this->silexApp->boot(); $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $this->silexApp->getEnv())); }
public function loadProviders(Application $app) { $app->register(new Provider\MonologServiceProvider(), $app['monolog.config']); $app->register(new Provider\DoctrineServiceProvider()); // connect to db // \SimpleRecord\Record::connection($app['db']); $models = ['post.model' => 'App\\Model\\Post', 'tag.model' => 'App\\Model\\Tag', 'post_tags.model' => 'App\\Model\\PostTags']; foreach ($models as $name => $class) { if (is_callable($class)) { $callable = $class; } else { $callable = function () use($class, $app) { return new $class($app); }; } $app[$name] = $app->factory($callable); } $app['migrations.output_writer'] = new OutputWriter(function ($message) { $output = new ConsoleOutput(); $output->writeln($message); }); $app['migrations.configuration'] = function () use($app) { $configuration = new Configuration($app['db'], $app['migrations.output_writer']); $configuration->setMigrationsDirectory($app['migrations']['directory']); $configuration->setName($app['migrations']['name']); $configuration->setMigrationsNamespace($app['migrations']['namespace']); $configuration->setMigrationsTableName($app['migrations']['table_name']); $configuration->registerMigrationsFromDirectory($app['migrations']['directory']); return $configuration; }; $app->register(new Provider\TwigServiceProvider(), ['twig.path' => $app['root.path'] . '/templates/', 'twig.form.templates' => ['bootstrap_3_horizontal_layout.html.twig'], 'twig.options' => ['cache' => $app['cache.path'] . '/twig']]); $app->register(new Provider\AssetServiceProvider(), ['assets.named_packages' => ['css' => ['version' => 'v1', 'base_path' => '/asset/css'], 'js' => ['version' => 'v1', 'base_path' => '/asset/js']]]); $app->register(new Provider\SecurityServiceProvider()); $app->register(new Provider\RoutingServiceProvider()); // $app->register(new Silex\Provider\HttpCacheServiceProvider(), [ // 'http_cache.cache_dir' => $app['cache.path'] . '/http', // ]); // $app->register(new Silex\Provider\HttpFragmentServiceProvider()); $app->register(new Provider\ValidatorServiceProvider()); $app->register(new Provider\LocaleServiceProvider()); $app->register(new Provider\TranslationServiceProvider()); $app->register(new Provider\CsrfServiceProvider()); $app->register(new Provider\FormServiceProvider()); $app->register(new Provider\ServiceControllerServiceProvider()); $app->register(new Provider\SessionServiceProvider()); $app->register(new \Paginator\Provider\PaginatorServiceProvider()); // $app->register(new \Sorien\Provider\PimpleDumpProvider(), ['dump.path' => $app['root.path']]); }
public function loadProviders(Application $app) { // $app['dump.path'] = $app['root.path']; // $app->register(new \Sorien\Provider\PimpleDumpProvider()); // $app->register(new Provider\MonologServiceProvider(), $app['monolog.config']); $app->register(new Provider\DoctrineServiceProvider()); $app->register(new \App\Provider\DoctrineORMServiceProvider()); $app['migrations.output_writer'] = new OutputWriter(function ($message) { $output = new ConsoleOutput(); $output->writeln($message); }); $app['migrations.configuration'] = function () use($app) { $configuration = new Configuration($app['db'], $app['migrations.output_writer']); $configuration->setMigrationsDirectory($app['migrations']['directory']); $configuration->setName($app['migrations']['name']); $configuration->setMigrationsNamespace($app['migrations']['namespace']); $configuration->setMigrationsTableName($app['migrations']['table_name']); $configuration->registerMigrationsFromDirectory($app['migrations']['directory']); return $configuration; }; $app->register(new Provider\ValidatorServiceProvider()); $app->register(new Provider\ServiceControllerServiceProvider()); }
<?php use App\Application; use App\ControllerProvider\ApiControllerProvider; use App\ControllerProvider\PageControllerProvider; use Cekurte\Environment\Environment; use Cekurte\Silex\Manager\Provider\ManagerServiceProvider; use Symfony\Component\HttpFoundation\Request; $app = new Application(); $app['debug'] = Environment::get('APP_DEBUG'); $app['cekurte.manager.providers'] = (require CONFIG_PATH . DS . 'manager.php'); $app->register(new ManagerServiceProvider()); Request::enableHttpMethodParameterOverride(); require CONFIG_PATH . DS . 'error.php'; $app->mount('/', new PageControllerProvider()); $app->mount('/api', new ApiControllerProvider()); $app->after($app["cors"]); return $app;
/** * Register a service provider with the application. * * @param \Illuminate\Support\ServiceProvider|string $provider * @param array $options * @param bool $force * @return \Illuminate\Support\ServiceProvider * @static */ public static function register($provider, $options = array(), $force = false) { //Method inherited from \Illuminate\Foundation\Application return \App\Application::register($provider, $options, $force); }