public function createApplication($namespace = 'Staq\\Core\\Ground', $baseUri = NULL, $platform = NULL) { if (empty($baseUri)) { $baseUri = $this->getDefaultBaseUri(); } if (empty($platform)) { $platform = 'prod'; if (\Staq\Util::isCli()) { if (!isset($argv[1])) { echo 'You must specify a platform.' . PHP_EOL; echo 'Ex: ' . $argv[0] . ' local' . PHP_EOL; die; } $platform = $argv[1]; } } $extensions = $this->findExtensions($namespace); if (!is_null(static::$autoloader)) { spl_autoload_unregister(array(static::$autoloader, 'autoload')); } static::$autoloader = new \Staq\Autoloader($extensions); spl_autoload_register(array(static::$autoloader, 'autoload')); static::$application = new \Stack\Application($extensions, $baseUri, $platform); static::$application->initialize(); return static::$application; }
public static function init() { // Load the user-defined test configuration file, if it exists; otherwise, load if (is_readable(__DIR__ . '/TestConfig.php')) { $testConfig = (include __DIR__ . '/TestConfig.php'); } else { $testConfig = (include __DIR__ . '/TestConfig.php.dist'); } $zf2ModulePaths = array(); if (isset($testConfig['module_listener_options']['module_paths'])) { $modulePaths = $testConfig['module_listener_options']['module_paths']; foreach ($modulePaths as $modulePath) { if ($path = static::findParentPath($modulePath)) { $zf2ModulePaths[] = $path; } } } $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR; $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : ''); static::initAutoloader(); // use ModuleManager to load this module and it's dependencies $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths))); $config = ArrayUtils::merge($baseConfig, $testConfig); $application = \Zend\Mvc\Application::init($config); // build test database $entityManager = $application->getServiceManager()->get('doctrine.entitymanager.orm_default'); $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager); $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata()); static::$application = $application; }
public static function init() { // Define application environment (production|staging|testing|development) defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APP_ENV') ? getenv('APP_ENV') : 'testing'); // Load the user-defined test configuration file, if it exists; otherwise, load if (is_readable(__DIR__ . '/TestConfig.php')) { $testConfig = (include __DIR__ . '/TestConfig.php'); } else { $testConfig = (include __DIR__ . '/TestConfig.php.dist'); } $zf2ModulePaths = array(); if (isset($testConfig['module_listener_options']['module_paths'])) { $modulePaths = $testConfig['module_listener_options']['module_paths']; foreach ($modulePaths as $modulePath) { if ($path = static::findParentPath($modulePath)) { $zf2ModulePaths[] = $path; } } } $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR; $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : ''); static::initAutoloader(); // use ModuleManager to load this module and it's dependencies $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths))); $config = ArrayUtils::merge($baseConfig, $testConfig); $serviceManager = new ServiceManager(new ServiceManagerConfig(isset($config['service_manager']) ? $config['service_manager'] : array())); $serviceManager->setService('ApplicationConfig', $config); $serviceManager->get('ModuleManager')->loadModules(); static::$application = $serviceManager->get('Application'); }
/** * Set up test */ public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); static::$application = new Application(static::$kernel); static::$application->setAutoExit(false); }
protected static function bootstrapApplication() { $kernel = new \AppKernel(static::$environment, static::$debug); $kernel->boot(); static::$application = new Application($kernel); static::$application->setAutoExit(false); }
public function bootstrap($event) { // Register a "render" event, at high priority (so it executes prior // to the view attempting to render) $app = $event->getParam('application'); static::$application = $app; $app->events()->attach('render', array($this, 'registerTwigStrategy'), 100); }
/** * */ public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); static::$application = new Application(static::$kernel); static::addDoctrineCommands(); static::rebuildDatabase(); }
/** * Create CBLib Application if not already created, and returns it for chaining * * @param string $type [optional] 'Web' or 'Cli' * @param array|object|InputInterface|null $input (array_merge(get, post) or argv if cli) * @param Config|callable|null $config The Config to use (or a closure returning it) * @return Application */ public static function createApplication($type = 'Web', $input = null, $config = null) { if (!static::$application) { // Define $app Containers 'Application' and 'Cms': $application = Application::createApplication($type); static::$application = $application; // Define $app Container 'Config': $application->set('Config', function () use($config, $application) { return Config::setMainConfig($config, $application); }, true, true); // Define $app Container 'DatabaseDriverInterface': $application->set('CBLib\\Database\\DatabaseDriverInterface', function (ApplicationContainerInterface $di) { return Database::createDatabaseDriver($di->getCms()); }, true)->alias('CBLib\\Database\\DatabaseDriverInterface', 'Database'); // Define $app Container 'Input': $application->set('CBLib\\Input\\InputInterface', function (ApplicationContainerInterface $di) use($type, $input) { // return static::getMainInput( static::$app, $type, $input ); return $di->getCms()->getInput($di, $type, $input); }, true)->alias('CBLib\\Input\\InputInterface', 'Input'); // Define $app Container 'Output': /** @noinspection PhpUnusedParameterInspection */ $application->set('CBLib\\Output\\OutputInterface', function (ApplicationContainerInterface $di, array $parameters) { return Output::createNew('html', $parameters); //TODO json+xml }, true)->alias('CBLib\\Output\\OutputInterface', 'Output'); // 'Router' and CBLib\Controller\RouterInterface service providers are defined in specific Cms constructor. // Define $app Container 'Session': $application->set('CBLib\\Session\\SessionInterface', '\\CBLib\\Session\\Session')->alias('CBLib\\Session\\SessionInterface', 'Session'); // Define $app Container 'SessionState': $application->set('CBLib\\Session\\SessionStateInterface', '\\CBLib\\Session\\SessionState')->alias('CBLib\\Session\\SessionStateInterface', 'SessionState'); // Define $app Container 'User': $application->set('CBLib\\Entity\\User\\User', function (ApplicationContainerInterface $di, array $parameters) { if (count($parameters) === 0) { throw new \UnexpectedValueException('Application::MyUser() called without a parameter'); } return User::getInstanceForContainerOnly($parameters[0], $di->getCms(), $di->getConfig()); })->alias('CBLib\\Entity\\User\\User', 'User'); $application->set('MyUser', function (ApplicationContainerInterface $di, array $parameters) { if (count($parameters) !== 0) { throw new \UnexpectedValueException('Application::User() called with a parameter'); } return User::getInstanceForContainerOnly(null, $di->getCms(), $di->getConfig()); }); // Define Language and translations, as well as the translations logger interface: $application->set('Language', 'CBLib\\Language\\CBTxt', true); $application->set('CBLib\\Language\\TranslationsLoggerInterface', function (ApplicationContainerInterface $di) { // Creates the logger: $translationsLogger = new TranslationsLogger(); // Registers after-render event to add the translations log at the end of the html body: $di->getCms()->registerOnAfterRenderBodyFilter(function ($body) use($translationsLogger) { return $translationsLogger->appendToBodyUsedStrings($body); }); return $translationsLogger; }, true); } return static::$application; }
protected static function getApplication() { if (!static::$application) { $options = static::$options; static::$client = static::createClient($options); static::$application = new Application(static::$client->getKernel()); static::$application->setAutoExit(false); } return static::$application; }
/** * Setup */ public function setUp() { static::$kernel = static::createKernel(); static::$kernel->boot(); static::$application = new Application(static::$kernel); static::$application->setAutoExit(false); $this->client = static::createClient(); static::$application->run(new ArrayInput(array('command' => 'doctrine:database:drop', '--no-interaction' => true, '--force' => true, '--quiet' => true))); static::$application->run(new ArrayInput(array('command' => 'doctrine:database:create', '--no-interaction' => true, '--quiet' => true))); static::$application->run(new ArrayInput(array('command' => 'doctrine:schema:create', '--no-interaction' => true, '--quiet' => true))); }
/** * Set up */ public function setUp() { try { $this->client = self::$_client = parent::createClient($this->getKernelOptions(), $this->getServerParameters()); static::$application = new Application(static::$kernel); static::$application->setAutoExit(false); $this->container = static::$kernel->getContainer(); } catch (Exception $e) { throw new RuntimeException(sprintf('Unable to start the application: %s', get_class($e) . ':' . $e->getMessage())); } $this->createSchema(); }
/** * Set up before class. * * @throws RuntimeException unable to start the application */ public static function setUpBeforeClass() { try { static::$kernel = static::createKernel(); static::$kernel->boot(); static::$application = new Application(static::$kernel); static::$application->setAutoExit(false); static::$container = static::$kernel->getContainer(); } catch (Exception $e) { throw new RuntimeException(sprintf('Unable to start the application: %s', $e->getMessage()), $e->getCode(), $e); } static::createSchema(); }
/** * Set up */ public function setUp() { gc_collect_cycles(); try { static::$kernel = static::createKernel(); static::$kernel->boot(); static::$application = new Application(static::$kernel); static::$application->setAutoExit(false); $this->container = static::$kernel->getContainer(); } catch (\Exception $e) { echo $e->getMessage(); die; } $this->createSchema(); }
/** * Setup the laravel application and run migrations when we first start */ public static function setUpBeforeClass() { ini_set('memory_limit', '-1'); $unitTesting = true; $testEnvironment = 'testing'; $GLOBALS['manuallyRequireDeviseRoutes'] = true; if (!static::$setup) { $loader = (require __DIR__ . '/../vendor/autoload.php'); $loader->setPsr4("App\\", __DIR__ . "/integrated/app/"); static::$application = (require __DIR__ . '/integrated/bootstrap/app.php'); static::$application->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); Config::set('database.default', 'sqlite'); static::setUpFixtures(); static::runMigrations(); Artisan::call('db:seed', array('--class' => 'DeviseSeeder')); Artisan::call('db:seed', array('--class' => 'DeviseTestsOnlySeeder')); static::manuallyRequireRoutes(); Mail::pretend(true); static::$setup = true; } return static::$application; }
/** * @param string $env */ public static function kernelBootstrap($env = AppKernel::ENV_DEV) { static::$application = static::getApplication($env); static::$application->boot(); }