laravel/helpers
Backwards-compatibility layer that restores Laravel 5.8 global helper functions in modern Laravel releases. Install via Composer and use legacy helpers while migrating to the equivalent Arr and Str methods.
array_get(), str_contains(), head(), etc.) as wrappers around modern Arr/Str classes. Reduces architectural friction during version jumps.Arr/Str methods). No database or external dependencies.Arr/Str.composer require laravel/helpers) with zero configuration. No manual patches or forks required.array_get($array, 'key')) transparently route to Arr::get($array, 'key'). No code changes needed for existing functionality.| Risk | Mitigation |
|---|---|
| Infinite loops (v1.8.0) | Fixed in v1.8.0+ for array_first, array_last, str_contains. Pin to ≥1.8.2. |
| PHP 8.1+ requirement | Drop support for older PHP versions in newer releases. Use v1.7.x for PHP 8.0. |
| No new helpers | Package is closed to additions. Plan to migrate to Arr/Str long-term. |
| Dependency conflicts | Minimal dependencies (illuminate/support). No known conflicts with Laravel. |
| Legacy code breakage | Test thoroughly with phpunit and legacy helper usage reports. |
| Removal complexity | Use static analysis (e.g., PHPStan) to track helper usage before uninstall. |
grep -r "array_get\|str_contains\|head\|last" app/)composer why-not laravel/helpers.)Arr/Str equivalents.)Arr/Str migration?illuminate/support (included in Laravel core). No conflicts with other packages.Arr, Str, Collection) without interference.composer why laravel/helpers + manual code review.composer require laravel/helpers@^1.8.2 --dev # Pin to LTS version
composer.json under "require-dev" if temporary.php artisan test).laravel/framework to target version (e.g., ^11.0).Arr::/Str:: equivalents.// Before
$value = array_get($array, 'key');
// After
$value = Arr::get($array, 'key');
composer remove laravel/helpers
Arr/Str directly.composer.json constraints).array_first, array_last, str_contains.func_get_args() for variadic function support (e.g., array_prepend).laravel/helpers.Arr/Str.illuminate/support).1.8.x) to avoid breaking changes.Arr/Str.dd(\Laravel\Helpers\HelperServiceProvider::class) to verify registration.AppServiceProvider:
use Illuminate\Support\Facades\Arr;
if (!function_exists('array_get')) {
function array_get($array, $key, $default = null) {
return Arr::get($array, $key, $default);
}
}
Arr/StrHow can I help you explore Laravel packages today?