Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon Debug not working

Hi,

I have added this code at the top of my bootstrap file (public/index.php) :

$debug = new \Phalcon\Debug(); $debug->listen();

...and then purposefully made an error in one of my PHP files. I get to see a blank screen, but not the desired Phalcon Debug screen.

I have checked previous discussions and removed the try/catch block from the bootstrap, but to no avail. Right now I can only debug by tailing the Apache log.

I must be overlooking something, but can't figure out what. Anyone got an idea? Thanks, Alex



34.2k

hey

Are you sure install xdebug?



3.1k
edited Oct '14

Yep, I have that installed. The strange thing is that it started working just earlier (perhaps it was a cache issue), but only for Phalcon-related functions/methods. If there is something wrong on the PHP level, there is no debug. I suppose this is the way it's intended?

In any case, it would be great if generated MySQL queries would also be included in this debug info.

Regards, Alex

Can you post the content of your index.php file? Here's what mine looks like:

<?php
$Debug = new \Phalcon\Debug();
$Debug->listen();

require '../app/config/bootstrap.php';

#
# Handle the requested URL
#
$App = new \Phalcon\Mvc\Application($DI);

#
# Echo the output
#
echo $App->handle()->getContent();


3.1k

Here it is:

<?php

  use Phalcon\Dispatcher,
    Phalcon\Mvc\Dispatcher as MvcDispatcher,
    Phalcon\Events\Manager as EventsManager;

    $debug = new \Phalcon\Debug();
  $debug->listen();

   //Register an autoloader
   $loader = new \Phalcon\Loader();
   $loader->registerDirs(array(
       '../app/controllers/',
       '../app/models/',
       '../app/components',
       '../app/plugins'
   ))->register();

   //Create a DI
   $di = new Phalcon\DI\FactoryDefault();

  //Setup the database service
      $di->set('db', function(){
          return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
              "host" => "localhost",
              "username" => "user",
              "password" => "pass",
              "dbname" => "db"
          ));
      });

   //Setup the view component
   $di->set('view', function(){
       $view = new \Phalcon\Mvc\View();
       $view->setViewsDir('../app/views/');
       return $view;
   });

   //Setup a base URI so that all generated URIs include the project folder
   $di->set('url', function(){
       $url = new \Phalcon\Mvc\Url();
       $url->setBaseUri('/phalconKickDish/');
       return $url;
   });

  /**
   * We register the events manager
   */
  $di->set('dispatcher', function() use ($di) {

    $eventsManager = $di->getShared('eventsManager');

    //Attach a listener
    $eventsManager->attach("dispatch:beforeDispatchLoop", function($event, $dispatcher) {

        $keyParams = array();
        $params = $dispatcher->getParams();

        //Use odd parameters as keys and even as values
        foreach ($params as $number => $value) {
            if ($number & 1) {
                $keyParams[$params[$number - 1]] = $value;
            }
        }

        //Override parameters
        $dispatcher->setParams($keyParams);
    });

    $dispatcher = new MvcDispatcher();
    $dispatcher->setEventsManager($eventsManager);

    return $dispatcher;
});

   //Handle the request
   $application = new \Phalcon\Mvc\Application($di);

   echo $application->handle()->getContent();

Are you generating an error, or an exception? A fatal error will stop output from being generated (due to output buffering), but it won't cause the debug screen to appear.



3.1k
Accepted
answer
edited Oct '14

I was indeed generating an error. So my understanding now is that it will only work with Exceptions, not core PHP errors.