The Arr class is macroable, so yes, you can add your own functions:
Arr::macro('foo', function ($array) {
// implement foo...
});
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am starting to use some of Laravel's helper functions, specifically the Array helper functions Arr::. But there are some specific array operations that I want to add to the built-in helpers.
Is there a way to add my own methods to the Arr class or the helpers.php file in the framework without actually editing the files in the /vendor directory?
If not, I'm fine with creating my own helper classes and using the Service Provider to autoload the class, but it would be nice if I could expand on the already existing class names.
The Arr class is macroable, so yes, you can add your own functions:
Arr::macro('foo', function ($array) {
// implement foo...
});
Please or to participate in this conversation.