stmllr.net

Debug Helper Extension for Extbase

by on stmllr.net

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

Tags

Comments

  1. Manfred

    Does not work for PHP 5.2...

  2. Steffen

    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

    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

    Hi,

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

    Many thanks in advance
    Andreas

  5. Andreas

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

    Hopefully someone finds a workaround?

  6. Steffen

    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.

  7. Andreas K.

    try {whatEverIsYourVariable} in your fluid template

  8. Andreas K.

    try <f:debug>{whatEverIsYourVariable}</f:debug> in your fluid template


    change > to < :) because do not know how to escape code here! (DONE!)

  9. Christian

    Thanks for the extension. I run it on Typo 6.0.2 for extension development with fluid und extbase, but I'm not really a programmer. Using it in the ext_localconf it works properly. I go in the Backend to "Installation" and the debug window pops out.
    But I want to use it in the action-classes, to test the variables there. But I don't get any output from there. Do you have a hint what I´m doing wrong.
    Thanks ahead!
    Christian

  10. Steffen

    Hi Christian, from TYPO3 4.7 and higher you don't need this extension.

    Just use:

    TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($variable);

  11. Christian

    Hi Steffen, thanks for your answer. I tried this function too, but I don't get an output of my variables in the action classes. It works only in the ext_localconf.php. Any idea, what I`m doing wrong?

  12. Steffen

    Hi Christian. I'd suggest to ask in the TYPO3 forum at http://forum.typo3.org/index.php/f/60/