sergiors/config-service-provider

此包已被废弃,不再维护。作者建议使用sergiors/lullaby包。

将yaml、php、目录配置加载到容器中

2.0.0 2016-05-18 20:39 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:52:30 UTC


README

安装

composer require sergiors/config-service-provider

如何使用

让我们假设你想加载以下yaml文件

imports:
    - { resource: config.yml }

twig.options:
    debug: false

db.options:
    driver: ~
    host: ~
    user: ~
    password: ~
    dbname: ~

routing.options:
    paths: %root_dir%/app/routing.yml

在你的php文件中

use Sergiors\Silex\Provider\ConfigServiceProvider;

$app->register(new ConfigServiceProvider(), [
    'config.filenames' => '%root_dir%/config/config_%env%.yml',
    'config.replacements' => [
        'root_dir' => dirname(__DIR__)
    ]
]);

$app['config.initializer']();

现在你可以访问 $app['twig.options']['debug'] 以及其他选项

许可证

MIT