13 September 2023
Sam
Freek
Expanding objects and array using Ray
When you send arrays and large objects to Ray, we'll display them beautifully in our app. Let's send the entire app instance of Laravel to Ray.
ray(app());
This is what that looks like in Ray.
Because that object is huge, we'll display it collapsed. You can click any of the arrows to open up a node and get more details.
In the latest version of Ray, we added the ability to open up nodes programmatically. So, if you're interested in what's in the reboundCallBacks
property, you can already expand it using the new expand
method.
ray(app())->expand('reboundCallBacks');
And now that reboundCallBacks
property is automatically opened in Ray, there is no need to manually open it anymore.
You can also pass multiple keys, and even use dot notation to reach nested nodes.
ray(app())->expand('reboundCallbacks', 'extenders.url');
This will also work with arrays.
Consider this array:
$myArray = [
'parentKey' => [
'childKey' => 'childValue',
],
'anotherParentKey' => [
'anotherChildKey' => 'anotherChildValue',
]
];
As demonstrated above, you can use expand
to specify which nodes should be opened in Ray.
ray($myArray)->expand('parentKey.childKey');
Instead of passing a string, you can also pass a number. In that case, Ray will expand all nodes up to that level.
Here's an example that will expand all nodes.
ray($myArray)->expand(2);
A lot of users asked for this feature, so we're happy to have this available in the latest release of Ray.
Understand and fix bugs faster
Ray is a desktop application that serves as the dedicated home for debugging output. Send, format and filter debug information from both local projects and remote servers.