LoginSignup
3
3

More than 5 years have passed since last update.

EC-CUBE4 の APP_ENV=prod でデバッグツールバーを使用する

Last updated at Posted at 2018-08-16

邪道かもしれませんが、 Production モード(APP_ENV=prod)で、 Symfony Profiler を使用したい場合だってありますよね。

composer install --dev

を実行してから、

以下の修正でデバッグツールバーを使用できるようになります。

diff --git a/app/config/eccube/bundles.php b/app/config/eccube/bundles.php
index 9f22986894..5543baeee8 100644
--- a/app/config/eccube/bundles.php
+++ b/app/config/eccube/bundles.php
@@ -21,9 +21,9 @@
     Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
     Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
     Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
-    Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'install' => true],
-    Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true, 'install' => true],
-    Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'install' => true],
+    Symfony\Bundle\DebugBundle\DebugBundle::class => ['all' => true],
+    Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['all' => true],
+    Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['all' => true],
     DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
     Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
     SunCat\MobileDetectBundle\MobileDetectBundle::class => ['all' => true],
diff --git a/app/config/eccube/packages/prod/web_profiler.yaml b/app/config/eccube/packages/prod/web_profiler.yaml
new file mode 100644
index 0000000000..e92166a7fd
--- /dev/null
+++ b/app/config/eccube/packages/prod/web_profiler.yaml
@@ -0,0 +1,6 @@
+web_profiler:
+    toolbar: true
+    intercept_redirects: false
+
+framework:
+    profiler: { only_exceptions: false }
diff --git a/app/config/eccube/routes/prod/web_profiler.yaml b/app/config/eccube/routes/prod/web_profiler.yaml
new file mode 100644
index 0000000000..c82beff2f6
--- /dev/null
+++ b/app/config/eccube/routes/prod/web_profiler.yaml
@@ -0,0 +1,7 @@
+web_profiler_wdt:
+    resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
+    prefix: /_wdt
+
+web_profiler_profiler:
+    resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
+    prefix: /_profiler

ワンライナーでやりたい方は、以下をどうぞ

curl -sS https://gist.githubusercontent.com/nanasess/ca8312478d565acc5f3563e9e50022a5/raw/9cb8bcd0616cbe5d409232f997ed0585877aa4f5/symfony-profiler-on-production.patch | git apply --no-add
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