LoginSignup
2
1

More than 5 years have passed since last update.

Phalconのデバッグコンポーネント導入

Posted at

公式にも記載のあるデバッグコンポーネントを導入してみました

まずは手順通りにpublic/index.phpに追記します

public/index.php
<?php
error_reporting(E_ALL);

(new \Phalcon\Debug())->listen(); // ここを追記

define('APP_PATH', realpath('..'));

try {

公式ではtry/catchを削除せよと書かれています。
ですが、リリース時にはないと困るので、削除するのも如何なものかと。
そこでちょっとひと手間加えてみます。

config.phpの最後にデバッグフラグ追加

app/config/config.php
        'baseUri'        => '/',
    ],
    'debug' => true
));

public/index.phpのcatch内でexceptionをthrowする

public/index.php
} catch (\Exception $e) {
    if ($config->debug) {
        throw $e;
    }
    echo $e->getMessage() . '<br>';
    echo '<pre>' . $e->getTraceAsString() . '</pre>';
}

これでconfigの値で制御できるようになりました。
めでたし。

2
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
2
1