forked from loafle/openapi-generator-original
* Huge update for php-mezzio-ph generator: - proper container support for data types - support for query parameter references and query parameter schema references - dependency update (PHP 7.3+, PathHandler 0.7+, DataTransfer 0.5+) * Sample regeneration after rebasing for php-mezzio-ph * - added custom CLI option for php-mezzio-ph to generate code using modern PHP syntax - removed obsolete php-mezzio-ph samples in samples/openapi3/server/petstore/php-mezzio-ph * - fixes for JavaDoc declarations that seems to break CI * - fix for outdated sample file
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Laminas\Config\Factory as ConfigFactory;
|
|
|
|
//Use Composer autoload that includes code both from ../src and ../vendor
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
//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 \Laminas\ServiceManager\ServiceManager($config['dependencies'] ?? []);
|
|
|
|
//Register full configuration as a service
|
|
$container->setService('config', $config);
|
|
$container->setAlias('Config', 'config');
|
|
|
|
return $container;
|