3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CakePHPでDebugモードとProductionモードを環境変数で切り替える

Posted at

CakePHPのConfig

app/Config/core.phpで以下のように切り替え設定をする。

if (env('WEB_APP_ENV') === 'production') {
	Configure::write('debug', 0);
} else {
	Configure::write('debug', 2);
}

Apacheの設定

以下のように設定する。

SetEnv WEB_APP_ENV production

例えば、/etc/httpd/conf.d配下にアプリ用の設定ファイルfoo.confがあって、次のような内容のときはこんな感じ。

設定前

Alias /foo /var/www/foo/app/webroot

<Location /foo>
    Order deny,allow
    Deny from all
    Allow from all
</Location>

設定後

Alias /foo /var/www/foo/app/webroot

<Location /foo>
    Order deny,allow
    Deny from all
    Allow from all
    SetEnv WEB_APP_ENV production
</Location>
3
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?