LoginSignup
10
7

More than 5 years have passed since last update.

EC-CUBE4の本番環境でデバッグモードを利用する方法

Last updated at Posted at 2018-12-02

EC-CUBE4では環境変数でデバッグモードに切り替えることができます。

本番環境
APP_ENV=prod
APP_DEBUG=0
開発環境
APP_ENV=dev
APP_DEBUG=1

しかし本番環境の環境変数を変更してデバッグモードを利用するとエンドユーザからのアクセスでもデバッグモードとなってしまいます。

デバッグモード用の index.php を用意する

EC-CUBE4でもEC-CUBE3の index_dev.php のような役割のファイルを作れます。

index.php をコピーして適当な推測されにくいファイル名のファイルを作成します。

cp index.php tekitou_na_suisoku_sare_nikui_file_name.php

作成したファイルの37行目付近に環境変数から $env$debug を設定している処理があるので、それぞれ dev , 1 を代入する処理に書き換えます。

vi tekitou_na_suisoku_sare_nikui_file_name.php
--- index.php   2018-09-17 00:02:26.000000000 +0900
+++ tekitou_na_suisoku_sare_nikui_file_name.php 2018-12-03 04:34:29.000000000 +0900
@@ -34,8 +34,8 @@
     }
 }

-$env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'dev';
-$debug = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : ('prod' !== $env);
+$env = 'dev';
+$debug = 1;

 if ($debug) {
     umask(0000);

このファイルからアクセスすると強制的にデバッグモードとなります。

必要がなくなればファイルは消しておきましょう。

rm tekitou_na_suisoku_sare_nikui_file_name.php
10
7
2

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
10
7