Short, Nice and Easy way
Definitely codecept_debug
with --debug
option is one of the right way.
But --debug
shows lot of verbosity which we might not need all time to see just a single variable's value.
And sometimes we might need to scroll a lot at CLI to reach at our variable
However there is one other short, nice and easy way
Assert the variable with true or anything random using assertSame
to display/var_dump the variable
Let's say I need to see what is inside $mango
and I am certain that it is not true or 'something random'
$I->assertTrue($mango)
$I->assertSame($mango, 'something random') // I am pretty sure $mango does not equals to 'something random'
Above statements will throw error printing out $mango
and the best part is that it will be printed at the bottom, so no need to scroll and no verbosity. Also in this way there is no need to add --debug
in CLI command
Limitation:
Out of 10 data types in PHP
Four scalar types:
bool
int
float (floating-point number, aka double)
string
Four compound types:
array
object
callable
iterable
And finally two special types:
resource
NULL
Above my way only works well with 6:
Four scalar types:
bool
int
float (floating-point number, aka double)
string
One compound types:
array
And finally one special types:
NULL
Value of object
, resource
will not be printed very well.