LoginSignup
15
14

More than 5 years have passed since last update.

[FuelPHP]開発環境による設定変更を活用する

Last updated at Posted at 2014-06-08

前回、.gitignoreを使った設定ファイルの変更を無視するやり方を書きました
http://qiita.com/maximum80/items/21d400b4ba3463cd9a87)

が、調べてみたところ、FuelPHPでは、開発環境によって読み込む設定ファイルを変更する事が出来るので、そのやり方を。

$ vim fuel/app/bootstrap.php

でbootstrap.phpをみると

bootstrap.php
/**
 * Your environment.  Can be set to any of the following:
 *
 * Fuel::DEVELOPMENT
 * Fuel::TEST
 * Fuel::STAGING
 * Fuel::PRODUCTION
 */
Fuel::$env = (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::DEVELOPMENT);

// Initialize the framework with the config file.
Fuel::init('config.php');

と書かれています。
これは、それぞれの開発環境によって変更が必要なファイルを指示してくれれば、
'FUEL_ENV'で指定された環境のconfigファイルを読みますよ。
という事。

また、configのディレクトリをみると

$ ls fuel/app/config
db.php config.php /development /test /staging /production

というような構成になっているのがわかります。

例えば、

「開発環境のときはデフォルトのエンコードをutf-8からshift-JISにしたい!」
という時は、

①config直下のconfig.php → 設定をutf-8に
②development内にconfig.phpをコピー → 設置をshift-JISに

という形にしておけば、それぞれの環境で別の対応をする事が可能です。

詳しいリファレンスはこちらをご覧ください。
http://press.nekoget.com/fuelphp_doc/general/environments.html

15
14
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
15
14