Var_dump() in SuiteCRM 7

Hi Everyone,
I’m new to suitecrm. I can’t figure out how to print the contents of a variable contained within a module’s method. Classic methods like “echo” “var_dump” and “print” have no effect. I also found a symphony composer component called VarDumper (The VarDumper Component (Symfony Docs)) that performs a similar function to what Laravel’s dd() function does, but I had trouble installing it.

Can someone help me?

Thank you

Hi, welcome to the Community! :tada:

You might try sending those outputs to the log file, instead of trying to echo them on to the screen.

Thanks for the advice, but I didn’t want to give up because I found it a very difficult way to work. So I persevered in search of a solution and I found it.

You can install the VarDumper Component, through the following procedure:

composer require --dev symfony/var-dumper

This involves using composer and also upgrading already installed packages.

We will also need to add this line at the top of the class where we want to dump the variables.

use Symfony\Component\VarDumper\VarDumper;

Then just use the function:

dump($var);
exit;

to get a screen containing all the information we need, and manipulate them to our liking.

At the moment I’m working with VarDumper version 4.4.0 on SuiteCRM 7.10.29. It is intended to be used ONLY FOR DEVELOPMENT PURPOSES, however this is a better way to work with SuiteCRM7.

I am at your disposal for any question.

Does that dump go in the middle of the rest of the content?

I mean, the app is producing HTML, does that extra variable info go in between? Because that can get really tricky.

For me, having it go on a separate place is a bonus, not a problem. Although I can see why you would prefer a nicely formatted output.

I created improved logging for SuiteCRM, but it’s been sitting there for years without being merged. That one has stack traces with variable values which is a really precious piece of debugging info.

See the docs I made here.

The Symfony stuff usually is brilliantly well-designed so I am grateful to learn about VarDumper, one day I’ll give it a try.

It all depends on how you are used to it.

For me, coming from Laravel, having to scroll through a log with an object that has thousands of fields means wasting a lot of time.

Otherwise, a well-organized screen, from which you can easily expand and collapse objects, arrays and variables, means being able to quickly and perfectly understand the structure and access data efficiently.

I recommend it.

1 Like

What about stack traces, does symfony have something nice for that?