定制 wcoppens/phalcon-config-loader-yaml 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wcoppens/phalcon-config-loader-yaml

Composer 安装命令:

composer require wcoppens/phalcon-config-loader-yaml

包简介

A symfony2 inspired Yaml config loader for Phalcon framework

README 文档

README

A symfony2 inspired Yaml config loader for Phalcon framework

What does it do?

This configuration loader is a extremely simple addon build on top of the ExtendedYaml class provided by PhalconIncubator. It loads always 3 Yaml configuration files having always the following naming convention:

  • parameters.yml (your dynamic configuration variables)
  • config.yml (the main configuration for the application)
  • config_{environment}.yml (the configuration which overwrites or add certain configs for the specific environment)

Setup

Use composer to install this bundle

composer require wcoppens/phalcon-config-loader-yaml

First create a config directory somewhere (i usually use app/config). Second create the a config.yml, parameters.yml and (possibly multiple) config_{environment}.yml files.

You can use the following examples as your config files:

#config.yml

database:
    adapter: Postgresql
    host: !parameter database_host
    username: !parameter database_username
    password: !parameter database_password
    dbname: !parameter database_name
    port: !parameter database_port
    schema: !parameter database_schema

application:
    controllersDir: !approot app/controllers/
#parameters.yml

parameters:
    database_host: somehost.net
    database_username: demo
    database_password: your-db-password
    database_name: demo
    database_port: 5432
    database_schema: public
#config_prod.yml

environment: production

Now you can load your config files by creating a new ConfigLoader instance for example in your loader file.

$config = new Wcoppens\Phalcon\ConfigLoader('Your config dir path', 'Your app-root path', 'environment');

/*
 * Now you can access all config variables just as with the original config system provided by Phalcon.
 *
 * Here some examples on how to access the variables.
 */
 
 echo $config->application->controllersDir;
 echo $config->parameters->database_name

统计信息

  • 总下载量: 41
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-20