forked from loafle/openapi-generator-original
* - support for PHP 7.1, Zend Expressive 3.2 and PathHander 0.4 for php-ze-ph generator * - fixed mess with petstore samples (added new files, removed obsolete files) * php-ze-ph: - overwriting "*/*" media type for producers with "n/a" (PathHandler does not support that cause it makes no sense to return response with "Content-Type: */*") - "array" return type declaration for handler methods with ambiguous "container" return type - better way to generate attribute annotation stub for request body data with ambiguous "container" type - fixed missing dependency in composer.json - minor optimization for container.php - samples for OAS3 petstore spec * php-ze-ph: - note about ext-yaml in stub README - updated .gitignore * php-ze-ph: - logging '*/*' replacement as warning
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Zend\Config\Factory as ConfigFactory;
|
|
|
|
//Use Composer autoload that includes code both from ../src and ../vendor
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
//Register Doctrine annotation autoload
|
|
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
|
|
|
|
//Path to file for caching full configuration
|
|
const CONFIG_CACHE_PATH = __DIR__ . '/../data/cache/config.php';
|
|
|
|
//Get full configuration
|
|
$config = [];
|
|
if (is_readable(CONFIG_CACHE_PATH)) {
|
|
$config = include CONFIG_CACHE_PATH;
|
|
} else {
|
|
//Register extra extension for YAML files
|
|
ConfigFactory::registerReader('yml', 'yaml');
|
|
|
|
//Combine all configuration files in right order
|
|
$config = ConfigFactory::fromFiles([
|
|
__DIR__ . '/config/data_transfer.yml',
|
|
__DIR__ . '/config/path_handler.yml',
|
|
__DIR__ . '/config/app.yml',
|
|
__DIR__ . '/config.yml',
|
|
]);
|
|
|
|
//Cache full configuration
|
|
if ($config['cache_configuration'] ?? false) {
|
|
if (!ConfigFactory::toFile(CONFIG_CACHE_PATH, $config)) {
|
|
throw new \RuntimeException('Failed to cache configuration');
|
|
}
|
|
}
|
|
}
|
|
|
|
//Create container
|
|
$container = new \Zend\ServiceManager\ServiceManager($config['dependencies'] ?? []);
|
|
|
|
//Register full configuration as a service
|
|
$container->setService('config', $config);
|
|
$container->setAlias('Config', 'config');
|
|
|
|
return $container;
|