We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Var_dump is taking forever to load?

I'm trying to var_dump an array of objects but it's not showing in browser and it's loading takes forever!

  // Fetch Category Related Video Blogs for each category
    foreach($videoBlogCategories as $key => $videoBlogCategory){
        $videoBlogCategoryObject = VideoBlogCategoryModel::findFirst($videoBlogCategory['id']);
        // Only Fetch First 7 Related Videos
        $videoBlogCategory['relatedVideos'] = array_slice($videoBlogCategoryObject->getVideoBlogs(), 0,7);

        var_dump($videoBlogCategory['relatedVideos']);exit;

    }

You are dumping info about an object (Model) which has references to the Di.

That means it will start dumping everything from the dispatcher to your db connection (services.php).

EIther setup your IDE with proper (remote) debugging, breakpoints and watchers, or dump the fields like so:

var_dump($videoBlogCategory['relatedVideos']->toArray());

This is why var_dump() is not a good idea when you're working with objects. Remember, you're not dumping only single variable (e.g. buffered string from memory) but entire tree of referenced objects etc.