LoginSignup
3
1

More than 3 years have passed since last update.

Phalconのconfigをymlで管理したい!環境[ENVIRONMENT]も切り分けたい!

Last updated at Posted at 2016-10-18

Phalconのconfigをymlで管理したい!

配列で管理するのもいいけど、個人的にymlの方が楽なのでymlで運用したい。
用途別にymlを分割したいので、複数のymlがあってもいいようにしたい。

なので、作ってみました。

php7+Phalcon3.0.xでしかテストしてませんが
基本、全てのバージョンで動くはず!

github

PhalconRouter

必要なライブラリ

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
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1