Apr. 29., 2011

Debug Helper Extension for Extbase

By Steffen Müller. Licensed under the Creative Commons License

Extbase in TYPO3 4.5 LTS has no built-in possibility to debug model objects. Whenever you try to var_dump() a model object or log it to t3lib_div::devLog(), you'll probably end up in out-of-memory exceptions. This article introduces an extension as a temporary solution for that.

What's wrong with var_dump()?

Because of circular dependencies in Extbase, dumps made with var_dump() will contain hugh amounts of useless object data of various framework classes. Your memory will probaly be exhausted and an exception is thrown. And you probably do not expect that with 1 GB of RAM reserved for PHP, do you?

A solution was backported from FLOW3 by Felix Oertel but it is still pending in the bugtracker. So we probably won't see it in TYPO3 core until 4.6. To fill the gap between now and then, I merged the code into an extension and provide it for download.

Extension Download

The extension ext_debug can be downloaded. It is in early alpha state and not yet finished. This is why it is not yet available in forge or TER. Be patient.

Extension Usage

e.g. in BlogController.php

[...]
public function indexAction() {
$blogs = $this->blogRepository->findAll();
foreach ($blogs as $blog) {
Tx_ExtDebug::var_dump($blog);
}
}
[...]

Result

 

Oops, an error occured!

Yes, I am aware of that. The debugger still needs some work. If you want to contribute, please do so and use the Extbase bugtracker on forge

--> Back to the list of articles

License

Licensed under creative commonsThis article is licensed under the Creative Commons License CC BY-SA 3.0. You are free to share (copy, distribute and transmit) and to remix (to adapt) the work under the following conditions:

  • You must attribute the work by mentioning the name of the author (Steffen Müller) and setting a link back to the original article using its URL.
  • If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

Comments

  1. Manfred wrote on July 7, 2011 at 19:23

    Does not work for PHP 5.2...

  2. Steffen wrote on July 29, 2011 at 10:21

    What exactly does mot work? Do you get any PHP errors in your logs?
    ATM I have no PHP 5.2 system at hand.

  3. Gernot wrote on August 3, 2011 at 13:32

    Fatal error: Call to undefined method Tx_Extbase_Reflection_PropertyReflection::setAccessible() in /home/[...]/public_html/typo3conf/ext/ext_debug/Classes/Error/Debugger.php on line 155

  4. Andreas wrote on October 20, 2011 at 23:26

    Hi,

    I get the very same error as Gernot.
    Does anybody have a solution for this problem?

    Many thanks in advance
    Andreas

  5. Andreas wrote on October 21, 2011 at 00:18

    Okay, this (http://php.net/manual/de/reflectionproperty.setaccessible.php) only works for PHP >= 5.3 :-(

    Hopefully someone finds a workaround?

  6. Steffen wrote on October 21, 2011 at 10:15

    I am sorry, I have no time to support legacy for PHP 5.2. Anyway, TYPO3 4.6 will be released in a few days and it depends on PHP 5.3.


Leave a comment:

This page uses static caches. Make sure you reload the page in your browser after posting a comment.

(will not be published)

CAPTCHA image for SPAM prevention Click here for audio version of the word to enter.

If you can't read the captcha word, please click to load a new image.
(You need Javascript turned on. Otherwise press the submit button and wait until the page has reloaded.)