Phalconのconfigをymlで管理したい!
配列で管理するのもいいけど、個人的にymlの方が楽なのでymlで運用したい。
用途別にymlを分割したいので、複数のymlがあってもいいようにしたい。
なので、作ってみました。
php7+Phalcon3.0.xでしかテストしてませんが
基本、全てのバージョンで動くはず!
github
必要なライブラリ
sudo yum install libyaml libyaml-devel php-pecl-yaml
Composer
{
"require": {
"ienaga/phalcon-router-for-yaml": "*"
}
}
BASE_PATH and APP_PATH
ベースのパスは!base_path
でappへのパスは!app_path
でできるようにする。
all:
application:
appDir: !app_path /
controllersDir: !app_path /controllers/
modelsDir: !app_path /models/
migrationsDir: !app_path /migrations/
viewsDir: !app_path /views/
pluginsDir: !app_path /plugins/
libraryDir: !app_path /library/
cacheDir: !base_path /cache/
baseUri: /project_name/
app/config/config.php
app/config/config.php
$configLoader = new \PhalconConfig\Loader();
return $configLoader
->setIgnore(["routing"]) // ignore yml names
->setEnvironment("stg") // default dev
->setBasePath(realpath(dirname(__FILE__) . '/../..'))
->load(); // @return \Phalcon\Config