公式にも記載のあるデバッグコンポーネントを導入してみました
まずは手順通りに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の値で制御できるようになりました。
めでたし。