本文整理匯總了PHP中Zend\Config\Factory::fromFiles方法的典型用法代碼示例。如果您正苦於以下問題:PHP Factory::fromFiles方法的具體用法?PHP Factory::fromFiles怎麽用?PHP Factory::fromFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Config\Factory
的用法示例。
在下文中一共展示了Factory::fromFiles方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processCommandTask
/**
* Process the command
*
* @return integer
*/
public function processCommandTask()
{
// load autoload configuration from project
$config = ConfigFactory::fromFiles(glob($this->params->projectConfigDir . '/autoload/{,*.}{global,development,local}.php', GLOB_BRACE));
// check for db config
if (empty($config) || !isset($config['db'])) {
$this->console->writeFailLine('task_crud_check_db_connection_no_config');
return 1;
}
// create db adapter instance
try {
$dbAdapter = new Adapter($config['db']);
} catch (InvalidArgumentException $e) {
$this->console->writeFailLine('task_crud_check_db_connection_config_inconsistent');
return 1;
}
// connect to database
try {
$connection = $dbAdapter->getDriver()->getConnection()->connect();
} catch (RuntimeException $e) {
$this->console->writeFailLine('task_crud_check_db_connection_failed');
return 1;
}
$this->params->dbAdapter = $dbAdapter;
return 0;
}
示例2: execute
/**
* Overwrite execute to override the default config file.
*
* If an alternative configuration file is provided we override the 'config'
* element in the Dependency Injection Container with a new instance. This
* new instance uses the phpdoc.tpl.xml as base configuration and applies
* the given configuration on top of it.
*
* Also, upon providing a custom configuration file, is the current working
* directory set to the directory containing the configuration file so that
* all relative paths for directory and file selections (and more) is based
* on that location.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$config_file = $input->getOption('config');
if ($config_file && $config_file !== 'none') {
$config_file = realpath($config_file);
// all relative paths mentioned in the configuration file should
// be relative to the configuration file.
// This means that if we provide an alternate configuration file
// that we need to go to that directory first so that paths can be
// calculated from there.
chdir(dirname($config_file));
}
if ($config_file) {
$container = $this->getContainer();
$container['config'] = $container->share(function () use($config_file) {
$files = array(__DIR__ . '/../../../data/phpdoc.tpl.xml');
if ($config_file !== 'none') {
$files[] = $config_file;
}
return \Zend\Config\Factory::fromFiles($files, true);
});
if (isset($container['config']->logging)) {
$level = (string) $container['config']->logging->level;
// null means the default is used
$logPath = isset($container['config']->logging->paths->default) ? (string) $container['config']->logging->paths->default : null;
// null means the default is used
$debugPath = isset($container['config']->logging->paths->errors) ? (string) $container['config']->logging->paths->errors : null;
$container->configureLogger($container['monolog'], $level, $logPath, $debugPath);
}
}
}
示例3: getSlimInstance
public function getSlimInstance()
{
$configPaths = sprintf('%s/config/{,*.}{global,%s,secret}.php', APPLICATION_PATH, SLIM_MODE);
$config = ConfigFactory::fromFiles(glob($configPaths, GLOB_BRACE));
$app = new Slim($config);
// TODO: Include app.php file
return $app;
}
示例4: testReturnsConfigObjectIfRequestedAndArrayOtherwise
public function testReturnsConfigObjectIfRequestedAndArrayOtherwise()
{
$files = array(__DIR__ . '/TestAssets/Ini/include-base.ini');
$configArray = Factory::fromFile($files[0]);
$this->assertTrue(is_array($configArray));
$configArray = Factory::fromFiles($files);
$this->assertTrue(is_array($configArray));
$configObject = Factory::fromFile($files[0], true);
$this->assertInstanceOf('Zend\\Config\\Config', $configObject);
$configObject = Factory::fromFiles($files, true);
$this->assertInstanceOf('Zend\\Config\\Config', $configObject);
}
示例5: execute
/**
* Overwrite execute to override the default config file.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$config_file = $input->getOption('config');
if ($config_file) {
$this->container['config'] = $this->container->share(function () use($config_file) {
$files = array(__DIR__ . '/../../../data/phpdoc.tpl.xml');
if ($config_file !== 'none') {
$files[] = $config_file;
}
return \Zend\Config\Factory::fromFiles($files, true);
});
}
}
示例6: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
if (!$serviceLocator->has('configType')) {
return false;
}
$type = $serviceLocator->get('configType');
if ($type === 'file') {
if (!$serviceLocator->has('configFiles')) {
return false;
}
$configFiles = $serviceLocator->get('configFiles');
if (!function_exists('yaml_parse')) {
\Zend\Config\Factory::registerReader('yaml', new \Zend\Config\Reader\Yaml('\\Symfony\\Component\\Yaml\\Yaml::parse'));
}
$config = Factory::fromFiles($configFiles);
return $config;
}
// @todo config type : string
return false;
}
示例7: execute
/**
* Overwrite execute to override the default config file.
*
* If an alternative configuration file is provided we override the 'config'
* element in the Dependency Injection Container with a new instance. This
* new instance uses the phpdoc.tpl.xml as base configuration and applies
* the given configuration on top of it.
*
* Also, upon providing a custom configuration file, is the current working
* directory set to the directory containing the configuration file so that
* all relative paths for directory and file selections (and more) is based
* on that location.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$config_file = $input->getOption('config');
if ($config_file && $config_file !== 'none') {
$config_file = realpath($config_file);
// all relative paths mentioned in the configuration file should
// be relative to the configuration file.
// This means that if we provide an alternate configuration file
// that we need to go to that directory first so that paths can be
// calculated from there.
chdir(dirname($config_file));
}
if ($config_file) {
$this->container['config'] = $this->container->share(function () use($config_file) {
$files = array(__DIR__ . '/../../../data/phpdoc.tpl.xml');
if ($config_file !== 'none') {
$files[] = $config_file;
}
return \Zend\Config\Factory::fromFiles($files, true);
});
}
}
示例8:
<?php
use Zend\Config\Factory;
return Factory::fromFiles(glob(__DIR__ . '/autoload/{,*.}{global,local}.php', GLOB_BRACE));
示例9: mergeGlobPath
/**
* Merge all config files matching a glob
*
* @param mixed $globPath
* @return ConfigListener
*/
protected function mergeGlobPath($globPath)
{
// @TODO Use GlobIterator
$config = ConfigFactory::fromFiles(glob($globPath, GLOB_BRACE));
$this->mergeTraversableConfig($config);
if ($this->getOptions()->getConfigCacheEnabled()) {
$this->updateCache();
}
return $this;
}
示例10: __invoke
public function __invoke()
{
return Factory::fromFiles(Glob::glob(__DIR__ . '/../config/{,*.}config.php', Glob::GLOB_BRACE));
}
示例11: getenv
<?php
use Zend\Config\Factory;
use Zend\Config\Writer\PhpArray;
$env = getenv('APP_ENV') ?: 'dev';
$mergedConfigFile = __DIR__ . '/../data/cache/config_cache.php';
// If in production and merged config exists, return it
if ($env === 'pro' && is_file($mergedConfigFile)) {
return include $mergedConfigFile;
}
// Merge configuration files
$mergedConfig = Factory::fromFiles(glob(__DIR__ . '/autoload/{,*.}{global,local}.php', GLOB_BRACE));
// If in production, cache merged config
if ($env === 'pro') {
$writer = new PhpArray();
$writer->toFile($mergedConfigFile, $mergedConfig);
}
// Finally, Return the merged configuration
return $mergedConfig;
示例12: mergePath
/**
* Merge all config files matching a glob
*
* @param mixed $path
* @return ConfigListener
*/
protected function mergePath($path)
{
switch ($path['type']) {
case self::STATIC_PATH:
$config = ConfigFactory::fromFile($path['path']);
break;
case self::GLOB_PATH:
$config = ConfigFactory::fromFiles(glob($path['path'], GLOB_BRACE));
break;
}
$this->mergeTraversableConfig($config);
if ($this->getOptions()->getConfigCacheEnabled()) {
$this->updateCache();
}
return $this;
}
示例13:
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Date: 9/5/15 - 9:39 PM
*/
/**
* The services configuration is used to set up a Zend\ServiceManager
* which is used as Inversion of Controller container in our application
* Please refer to the official documentation:
* http://framework.zend.com/manual/current/en/modules/zend.service-manager.html
*/
$servicesConfig = ['invokables' => [\Prooph\ServiceBus\Plugin\InvokeStrategy\OnEventStrategy::class => \Prooph\ServiceBus\Plugin\InvokeStrategy\OnEventStrategy::class, \Prooph\ProophessorDo\App\View\Helper\RiotTag::class => \Prooph\ProophessorDo\App\View\Helper\RiotTag::class, \Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator::class => \Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator::class], 'factories' => [\Zend\Expressive\Application::class => \Zend\Expressive\Container\ApplicationFactory::class, \Prooph\ProophessorDo\App\Commanding\API::class => \Prooph\ProophessorDo\Container\App\Commanding\APIFactory::class, 'doctrine.connection.default' => Prooph\ProophessorDo\Container\Infrastructure\DoctrineDbalConnectionFactory::class, \Prooph\EventStore\EventStore::class => \Prooph\EventStore\Container\EventStoreFactory::class, \Prooph\EventStore\Snapshot\SnapshotStore::class => \Prooph\EventStore\Container\Snapshot\SnapshotStoreFactory::class, 'Prooph\\EventStore\\Adapter\\MongoDb\\MongoDbEventStoreAdapter' => 'Prooph\\EventStore\\Adapter\\MongoDb\\Container\\MongoDbEventStoreAdapterFactory', 'Prooph\\EventStore\\Adapter\\Doctrine\\DoctrineEventStoreAdapter' => 'Prooph\\EventStore\\Adapter\\Doctrine\\Container\\DoctrineEventStoreAdapterFactory', 'Prooph\\EventStore\\Snapshot\\Adapter\\Doctrine\\DoctrineSnapshotAdapter' => 'Prooph\\EventStore\\Snapshot\\Adapter\\Doctrine\\Container\\DoctrineSnapshotAdapterFactory', 'Prooph\\EventStore\\Snapshot\\Adapter\\MongoDb\\MongoDbSnapshotAdapter' => 'Prooph\\EventStore\\Snapshot\\Adapter\\MongoDb\\Container\\MongoDbSnapshotAdapterFactory', 'Prooph\\EventStore\\Snapshot\\Adapter\\Memcached\\MemcachedSnapshotAdapter' => 'Prooph\\EventStore\\Snapshot\\Adapter\\Memcached\\Container\\MemcachedSnapshotAdapterFactory', \Prooph\ServiceBus\CommandBus::class => \Prooph\ServiceBus\Container\CommandBusFactory::class, \Prooph\ServiceBus\EventBus::class => \Prooph\ServiceBus\Container\EventBusFactory::class, \Prooph\EventStoreBusBridge\TransactionManager::class => \Prooph\EventStoreBusBridge\Container\TransactionManagerFactory::class, \Prooph\EventStoreBusBridge\EventPublisher::class => \Prooph\EventStoreBusBridge\Container\EventPublisherFactory::class, \Zend\Expressive\Router\RouterInterface::class => \Prooph\ProophessorDo\Container\App\Routing\AuraRouterFactory::class, \Prooph\ProophessorDo\App\Action\Home::class => \Prooph\ProophessorDo\Container\App\Action\HomeFactory::class, \Prooph\ProophessorDo\App\Action\UserList::class => \Prooph\ProophessorDo\Container\App\Action\UserListFactory::class, \Prooph\ProophessorDo\App\Action\UserRegistration::class => \Prooph\ProophessorDo\Container\App\Action\UserRegistrationFactory::class, \Prooph\ProophessorDo\App\Action\UserTodoList::class => \Prooph\ProophessorDo\Container\App\Action\UserTodoListFactory::class, \Prooph\ProophessorDo\App\Action\UserTodoForm::class => \Prooph\ProophessorDo\Container\App\Action\UserTodoFormFactory::class, \Zend\Expressive\Template\TemplateInterface::class => \Zend\Expressive\Container\Template\ZendViewFactory::class, \Zend\View\HelperPluginManager::class => \Prooph\ProophessorDo\Container\App\View\ViewHelperPluginManagerFactory::class, \Prooph\ProophessorDo\Model\User\Handler\RegisterUserHandler::class => \Prooph\ProophessorDo\Container\Model\User\RegisterUserHandlerFactory::class, \Prooph\ProophessorDo\Model\User\UserCollection::class => \Prooph\ProophessorDo\Container\Infrastructure\Repository\EventStoreUserCollectionFactory::class, \Prooph\ProophessorDo\Model\Todo\Handler\PostTodoHandler::class => \Prooph\ProophessorDo\Container\Model\Todo\PostTodoHandlerFactory::class, \Prooph\ProophessorDo\Model\Todo\Handler\MarkTodoAsDoneHandler::class => \Prooph\ProophessorDo\Container\Model\Todo\MarkTodoAsDoneHandlerFactory::class, \Prooph\ProophessorDo\Model\Todo\Handler\AddDeadlineToTodoHandler::class => \Prooph\ProophessorDo\Container\Model\Todo\AddDeadlineToTodoHandlerFactory::class, \Prooph\ProophessorDo\Model\Todo\TodoList::class => \Prooph\ProophessorDo\Container\Infrastructure\Repository\EventStoreTodoListFactory::class, \Prooph\ProophessorDo\Projection\User\UserProjector::class => \Prooph\ProophessorDo\Container\Projection\User\UserProjectorFactory::class, \Prooph\ProophessorDo\Projection\User\UserFinder::class => \Prooph\ProophessorDo\Container\Projection\User\UserFinderFactory::class, \Prooph\ProophessorDo\Projection\Todo\TodoProjector::class => \Prooph\ProophessorDo\Container\Projection\Todo\TodoProjectorFactory::class, \Prooph\ProophessorDo\Projection\Todo\TodoFinder::class => \Prooph\ProophessorDo\Container\Projection\Todo\TodoFinderFactory::class]];
/**
* The application config is merged from several files
* and then registered as a service with the name "config"
* in the service manager
*
* Note: Config merge (recursive array merge) can become an expensive task.
* In a production system you should cache the merged config.
* We don't cache it in this demo to keep the system set up as simple as possible.
*/
$appConfig = \Zend\Config\Factory::fromFiles([__DIR__ . '/prooph.php', __DIR__ . '/event_store.local.php', __DIR__ . '/dbal_connection.local.php', __DIR__ . '/routes.php', __DIR__ . '/templates.php']);
$servicesConfig['services']['config'] = $appConfig;
$mongoClientFactoryConfigFile = __DIR__ . '/mongo_client.local.php';
if (file_exists($mongoClientFactoryConfigFile)) {
$mongoClientFactoryConfig = (include $mongoClientFactoryConfigFile);
$servicesConfig['factories']['mongo_client'] = $mongoClientFactoryConfig['mongo_client'];
}
//Finally we return the ready to use service manager
return new \Zend\ServiceManager\ServiceManager(new \Zend\ServiceManager\Config($servicesConfig));
示例14: define
<?php
if (!defined('SLIM_MODE')) {
define('SLIM_MODE', getenv('SLIM_MODE') ?: 'production');
}
define('APPLICATION_PATH', realpath(dirname(__DIR__)));
require_once __DIR__ . '/../vendor/autoload.php';
require_once APPLICATION_PATH . '/vendor/autoload.php';
use Zend\Config\Factory as ConfigFactory;
$configPaths = sprintf('%s/config/{,*.}{global,%s,secret}.php', APPLICATION_PATH, SLIM_MODE);
$config = ConfigFactory::fromFiles(glob($configPaths, GLOB_BRACE));
require_once APPLICATION_PATH . '/src/app.php';
// Run app
$app->run();
示例15: addConfiguration
/**
* Adds the Configuration object to the DIC.
*
* phpDocumentor first loads the template config file (/data/phpdoc.tpl.xml)
* and then the phpdoc.dist.xml, or the phpdoc.xml if it exists but not both,
* from the current working directory.
*
* The user config file (either phpdox.dist.xml or phpdoc.xml) is merged
* with the template file.
*
* @return void
*/
protected function addConfiguration()
{
$this['config'] = $this->share(function () {
$user_config_file = file_exists(getcwd() . DIRECTORY_SEPARATOR . 'phpdoc.xml') ? getcwd() . DIRECTORY_SEPARATOR . 'phpdoc.xml' : getcwd() . DIRECTORY_SEPARATOR . 'phpdoc.dist.xml';
$config_files = array(__DIR__ . '/../../data/phpdoc.tpl.xml');
if (is_readable($user_config_file)) {
$config_files[] = $user_config_file;
}
return Factory::fromFiles($config_files, true);
});
}