当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::init方法代码示例

本文整理汇总了PHP中Zend\Mvc\Application::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::init方法的具体用法?PHP Application::init怎么用?PHP Application::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Mvc\Application的用法示例。


在下文中一共展示了Application::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     $bootstrap = \Zend\Mvc\Application::init(include 'config/application.config.php');
     $categoryData = array('id_category' => 1, 'name' => 'Project Manager');
     $category = new Category();
     $category->exchangeArray($categoryData);
     $resultSetCategory = new ResultSet();
     $resultSetCategory->setArrayObjectPrototype(new Category());
     $resultSetCategory->initialize(array($category));
     $mockCategoryTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select'), array(), '', false);
     $mockCategoryTableGateway->expects($this->any())->method('select')->with()->will($this->returnValue($resultSetCategory));
     $categoryTable = new CategoryTable($mockCategoryTableGateway);
     $jobData = array('id_job' => 1, 'id_category' => 1, 'type' => 'typeTest', 'company' => 'companyTest', 'logo' => 'logoTest', 'url' => 'urlTest', 'position' => 'positionTest', 'location' => 'locaitonTest', 'description' => 'descriptionTest', 'how_to_play' => 'hotToPlayTest', 'is_public' => 1, 'is_activated' => 1, 'email' => 'emailTest', 'created_at' => '2012-01-01 00:00:00', 'updated_at' => '2012-01-01 00:00:00');
     $job = new Job();
     $job->exchangeArray($jobData);
     $resultSetJob = new ResultSet();
     $resultSetJob->setArrayObjectPrototype(new Job());
     $resultSetJob->initialize(array($job));
     $mockJobTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select'), array(), '', false);
     $mockJobTableGateway->expects($this->any())->method('select')->with(array('id_category' => 1))->will($this->returnValue($resultSetJob));
     $jobTable = new JobTable($mockJobTableGateway);
     $this->controller = new IndexController($categoryTable, $jobTable);
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = $bootstrap->getMvcEvent();
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setEventManager($bootstrap->getEventManager());
     $this->controller->setServiceLocator($bootstrap->getServiceManager());
 }
开发者ID:Lebe1ge,项目名称:JobeetForZF2,代码行数:30,代码来源:IndexControllerTest.php

示例2: init

 /**
  * Set up application environment
  *
  * This sets up the PHP environment, loads the provided module and returns
  * the MVC application.
  *
  * @param string $module Module to load
  * @param bool $addTestConfig Add config for test environment (enable all debug options, no config file)
  * @param array $applicationConfig Extends default application config
  * @return \Zend\Mvc\Application
  * @codeCoverageIgnore
  */
 public static function init($module, $addTestConfig = false, $applicationConfig = array())
 {
     // Set up PHP environment.
     session_cache_limiter('nocache');
     // Default headers to prevent caching
     return \Zend\Mvc\Application::init(array_replace_recursive(static::getApplicationConfig($module, $addTestConfig), $applicationConfig));
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:19,代码来源:Application.php

示例3: iniializeZendFramework

 /**
  * @BeforeSuite
  */
 public static function iniializeZendFramework()
 {
     if (self::$zendApp === null) {
         $config = (require __DIR__ . '/../../config/application.config.php');
         self::$zendApp = Application::init($config);
     }
 }
开发者ID:pawelryznar,项目名称:php-ddd-cargo-sample,代码行数:10,代码来源:FeatureContext.php

示例4: init

 public static function init()
 {
     /**
      * Load Test Config to include other modules we require
      */
     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);
     \Zend\Mvc\Application::init($config);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
     static::$config = $config;
 }
开发者ID:netglue,项目名称:zf2-money-module,代码行数:33,代码来源:bootstrap.php

示例5: init

 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;
 }
开发者ID:VOONWerbeagentur,项目名称:SoliantEntityAudit,代码行数:30,代码来源:Bootstrap.php

示例6: getApplicationCommands

 /**
  * Gets application commands
  *
  * @return array
  */
 protected function getApplicationCommands()
 {
     $setupCommands = [];
     $toolsCommands = [];
     $modulesCommands = [];
     $bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP);
     $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER);
     $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
     $bootstrap = Bootstrap::create(BP, $params);
     $objectManager = $bootstrap->getObjectManager();
     if (class_exists('Magento\\Setup\\Console\\CommandList')) {
         $serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager();
         $setupCommandList = new \Magento\Setup\Console\CommandList($serviceManager);
         $setupCommands = $setupCommandList->getCommands();
     }
     if (class_exists('Magento\\Tools\\Console\\CommandList')) {
         $toolsCommandList = new \Magento\Tools\Console\CommandList();
         $toolsCommands = $toolsCommandList->getCommands();
     }
     if ($objectManager->get('Magento\\Framework\\App\\DeploymentConfig')->isAvailable()) {
         $commandList = $objectManager->create('Magento\\Framework\\Console\\CommandList');
         $modulesCommands = $commandList->getCommands();
     }
     $commandsList = array_merge($setupCommands, $toolsCommands, $modulesCommands);
     return $commandsList;
 }
开发者ID:nja78,项目名称:magento2,代码行数:31,代码来源:Cli.php

示例7: init

 /**
  * @see \Zend\Mvc\Application#init()
  * @param array $configuration
  * @return RealZendApplication
  */
 public static function init($configuration = array())
 {
     Exception\ErrorException::$oldErrorHandler = set_error_handler("\\Netis\\Exception\\ErrorException::errorHandler");
     Environment::setEnv(isset($configuration['env']) ? $configuration['env'] : Environment::ENV_PRODUCTION);
     self::detectLoader($configuration);
     return parent::init($configuration);
 }
开发者ID:athemcms,项目名称:netis,代码行数:12,代码来源:ZendApplication.php

示例8: getApplication

 public static function getApplication()
 {
     self::assertZf();
     self::chdirToAppRoot();
     $configPath = self::findAppConfigPath();
     return Application::init(require $configPath);
 }
开发者ID:brs-software,项目名称:stdlib,代码行数:7,代码来源:ZfHelper.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Start up application with supplied config...');
     $config = $input->getArgument('applicationConfig');
     $path = stream_resolve_include_path($config);
     if (!is_readable($path)) {
         throw new \InvalidArgumentException("Invalid loader path: {$config}");
     }
     // Init the application once using given config
     // This way the late static binding on the AspectKernel
     // will be on the goaop-zf2-module kernel
     \Zend\Mvc\Application::init(include $path);
     if (!class_exists(AspectKernel::class, false)) {
         $message = "Kernel was not initialized yet. Maybe missing module Go\\ZF2\\GoAopModule in config {$path}";
         throw new \InvalidArgumentException($message);
     }
     $kernel = AspectKernel::getInstance();
     $options = $kernel->getOptions();
     if (empty($options['cacheDir'])) {
         throw new \InvalidArgumentException('Cache warmer require the `cacheDir` options to be configured');
     }
     $enumerator = new Enumerator($options['appDir'], $options['includePaths'], $options['excludePaths']);
     $iterator = $enumerator->enumerate();
     $totalFiles = iterator_count($iterator);
     $output->writeln("Total <info>{$totalFiles}</info> files to process.");
     $iterator->rewind();
     set_error_handler(function ($errno, $errstr, $errfile, $errline) {
         throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
     });
     $index = 0;
     $errors = [];
     foreach ($iterator as $file) {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
             $output->writeln("Processing file <info>{$file->getRealPath()}</info>");
         }
         $isSuccess = null;
         try {
             // This will trigger creation of cache
             file_get_contents(FilterInjectorTransformer::PHP_FILTER_READ . SourceTransformingLoader::FILTER_IDENTIFIER . '/resource=' . $file->getRealPath());
             $isSuccess = true;
         } catch (\Exception $e) {
             $isSuccess = false;
             $errors[$file->getRealPath()] = $e;
         }
         if ($output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
             $output->write($isSuccess ? '.' : '<error>E</error>');
             if (++$index % 50 == 0) {
                 $output->writeln("({$index}/{$totalFiles})");
             }
         }
     }
     restore_error_handler();
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
         foreach ($errors as $file => $error) {
             $message = "File {$file} is not processed correctly due to exception: {$error->getMessage()}";
             $output->writeln($message);
         }
     }
     $output->writeln('<info>Done</info>');
 }
开发者ID:goaop,项目名称:goaop-zf2-module,代码行数:63,代码来源:Zf2WarmupCommand.php

示例10: init

 /**
  * {@inheritDoc}
  * @return self
  */
 public static function init($configuration = array())
 {
     $defaults = array('module_listener_options' => array(), 'modules' => array(), 'service_manager' => array());
     $configuration = ArrayUtils::merge($defaults, $configuration);
     $configuration['modules'][] = 'ZeffMu';
     return parent::init($configuration);
 }
开发者ID:binarykitten,项目名称:zeffmu,代码行数:11,代码来源:App.php

示例11: __construct

 /**
  * @param string $name  application name
  * @param string $version application version
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
 {
     $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager();
     $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager);
     if (!$generationDirectoryAccess->check()) {
         $output = new ConsoleOutput();
         $output->writeln('<error>Command line user does not have read and write permissions on var/generation directory.  Please' . ' address this issue before using Magento command line.</error>');
         exit(0);
     }
     /**
      * Temporary workaround until the compiler is able to clear the generation directory
      * @todo remove after MAGETWO-44493 resolved
      */
     if (class_exists(CompilerPreparation::class)) {
         $compilerPreparation = new CompilerPreparation($this->serviceManager, new ArgvInput(), new File());
         $compilerPreparation->handleCompilerEnvironment();
     }
     if ($version == 'UNKNOWN') {
         $directoryList = new DirectoryList(BP);
         $composerJsonFinder = new ComposerJsonFinder($directoryList);
         $productMetadata = new ProductMetadata($composerJsonFinder);
         $version = $productMetadata->getVersion();
     }
     parent::__construct($name, $version);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:Cli.php

示例12: testControllerRegistered

 public function testControllerRegistered()
 {
     $app = \Zend\Mvc\Application::init(require __DIR__ . '/_files/config/application.config.php');
     $serviceManager = $app->getServiceManager();
     $controllerManager = $serviceManager->get('ControllerManager');
     $controller = $controllerManager->get(\Autowp\Image\Controller\ConsoleController::class);
     $this->assertInstanceOf(\Autowp\Image\Controller\ConsoleController::class, $controller);
 }
开发者ID:autowp,项目名称:image,代码行数:8,代码来源:ZFIntegrationTest.php

示例13: testApplicationUsesLoggedPluginManagers

 public function testApplicationUsesLoggedPluginManagers()
 {
     $sm = Application::init(array('modules' => array('OcraServiceManager'), 'module_listener_options' => array('module_paths' => array(), 'config_glob_paths' => array())))->getServiceManager();
     $pluginManagers = array('ServiceManager', 'ControllerLoader', 'ControllerPluginManager', 'FilterManager', 'FormElementManager', 'HydratorManager', 'InputFilterManager', 'PaginatorPluginManager', 'RoutePluginManager', 'SerializerAdapterManager', 'ValidatorManager', 'ViewHelperManager');
     foreach ($pluginManagers as $pluginManager) {
         $this->assertInstanceOf('ProxyManager\\Proxy\\AccessInterceptorInterface', $sm->get($pluginManager));
     }
 }
开发者ID:rhodium289,项目名称:sandbox,代码行数:8,代码来源:ApplicationRunTest.php

示例14: setup

 protected function setup()
 {
     $this->application = Application::init(self::$applicationConfig);
     $this->serviceManager = $this->application->getServiceManager();
     $this->couchDBClient = $this->getDocumentManager()->getCouchDBClient();
     $couchDBClient = $this->couchDBClient;
     $couchDBClient->deleteDatabase($couchDBClient->getDatabase());
     $couchDBClient->createDatabase($couchDBClient->getDatabase());
 }
开发者ID:Ellipizle,项目名称:DoctrineCouchODMModule,代码行数:9,代码来源:AbstractTest.php

示例15: run

 public static function run()
 {
     chdir(dirname(self::initParentPath('vendor')));
     putenv('ZF2_PATH=vendor/zendframework/zendframework/library');
     putenv('APPLICATION_ENV=phpunit');
     $loader = (include 'vendor/autoload.php');
     Application::init(self::getConfig());
     self::initDatabase();
 }
开发者ID:mhilker,项目名称:usermanager,代码行数:9,代码来源:Bootstrap.php


注:本文中的Zend\Mvc\Application::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。