Take the 2-minute tour ×

I started out in cake 1.2.6 a short time ago and liked the controller dump feature because it showed me what was going on, and at which points in my app the objects were instantiated, and their contents.

In 1.3 how can I find out the names of instantiated objects, and how do I get a dump of them?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

If you put the following code inside function index() of your usersController (for example):

echo debug($this);

You can browse to '/users' to see the hierarchy.

share|improve this answer
Ah, then I guess I can add it to the before_filter of my app_controller and get a dump of all controllers again. Thanks. –  Owen Jul 31 '10 at 13:38
I just tested that on one of my apps and it wouldn't work. I'm not sure if that means that it won't on any app, though. You may have to stick it in beforeRender. –  Marshall Thompson Jul 31 '10 at 15:23
Sometimes I also find it useful to put an exit; right after so the layout is not messing with the indentation. Of course it will stop the rendering, but it makes for easier reading of $this. –  Chuck Burgess Aug 10 '10 at 19:16
I don't know why I haven't thought about that before. That really cleans things up! –  Marshall Thompson Aug 12 '10 at 14:27
add comment

Your Answer


