User Tools

Site Tools


php:improve_zf2_debugging_process

Improve ZF2 Debugging Process

25.06.2014

ZF2-Whoops Module

Check this module here.

  • update your composer.json with

"require": {
    ...
	"ghislainf/zf2-whoops": "dev-master"
    ...	
}

  • run php composer.phar update
  • enable the module in application.config.php

'modules' => array(
    ...
        'Zf2Whoops',
    ...
        'Application',
    ),

Debug AJAX with ease (including those pesky 500 errors)

  • install FirePHP addon for Firefox (or your browser of choice)
  • install FirePHP package with composer.json and run composer.phar update

"require": {
    ...
	"firephp/firephp-core" : "dev-master"
    ...	
}

  • fill the following in Module.php, onBootstrap function:

        //FIREPHP Logger
        $logger = new \Zend\Log\Logger();
        $writerFirebug = new \Zend\Log\Writer\FirePhp();
        $logger->addWriter($writerFirebug, 0);
        $logger->registerErrorHandler($logger);
        $logger->registerExceptionHandler($logger);
        $logger->info('Firephp logger'.__FILE__.__LINE__);
 
        register_shutdown_function(function () use ($logger) {
            if ($e = error_get_last()) {
                $logger->ERR($e['message'] . " in " . $e['file'] . ' line ' . $e['line']);
                $logger->__destruct();
            }
        });

Now you should have 500 Error details in your Console tab in FireBug (FF).

php/improve_zf2_debugging_process.txt · Last modified: 2014/06/25 12:51 by admin