maxwell2022/yamlconfigprovider

v1.0.0 2014-02-06 00:38 UTC

This package is not auto-updated.

Last update: 2024-09-24 06:21:30 UTC


README

Silex 提供者,用于解析 YAML 配置文件并在注册缓存的情况下进行缓存

Latest Stable Version Total Downloads

此提供者受 deralex 启发

不同之处在于配置是

  • 懒加载
  • 缓存以避免在每次页面加载时解析(如果已注册缓存)

安装

使用您的 composer.json

{
    "maxwell2022/yamlconfigprovider": "dev-master"
}
$ ./composer.phar update

提供者注册

$app->register(new \Maxwell2022\Silex\Provider\YamlConfigProvider(), array(
    'config.file' => __DIR__.'/config/config.yml'
));

使用缓存的示例

$app['cache.path'] = __DIR__.'/../cache';

$app->register(new \CHH\Silex\CacheServiceProvider, array(
    'cache.options' => array(
        'default' => array('driver' => 'apc'),
        'file' => array(
            'driver' => 'filesystem',
            'directory' => $app['cache.path']
        )
    )
));

$app->register(new \Maxwell2022\Silex\Provider\YamlConfigProvider(), array(
    'config.file' => __DIR__.'/Config/config.yml',
));