hyperf/stdlib
Hyperc/stdlib provides foundational utilities for the Hyperf ecosystem: common helpers, collections, array and string tools, and lightweight polyfills used across components. A small, reusable standard library for building high-performance PHP apps and services.
hyperf/stdlib is Hyperf-specific, making it a poor fit for Laravel projects. Laravel has its own ecosystem (e.g., Illuminate\Support\Arr, Illuminate\Support\Str) with deep integration into the framework’s DI container, service providers, and Facade system. Forcing Hyperf utilities into Laravel would require abstraction layers (e.g., facades, adapters), adding complexity without clear benefits.Collection may use coroutine-aware methods (e.g., asyncMap()), which Laravel’s Collection lacks.Arr::dot() or Str::of() have no direct equivalents in hyperf/stdlib.spatie/laravel-array, nunomaduro/collision). Introducing Hyperf utilities would duplicate effort and fragment the codebase.hyperf/stdlib into Laravel would require:
Facade::make(Hyperf\Stdlib\Arr::class)), which is overkill for simple array/string operations.php-di, adding overhead.Hyperf\Stdlib and Illuminate\Support namespaces could lead to collisions (e.g., Arr, Str).// Laravel-native (fast)
$value = Arr::get($array, 'key');
// Hyperf via facade (slow)
$value = HyperfArr::get($array, 'key'); // Extra layer of abstraction
stdlib.Collection::chunk() behavior differences).hyperf/stdlib are negligible compared to:
spatie/laravel-array, laravelcollective/html) that solve specific pain points.hyperf/stdlib’s Arr with Illuminate\Support\Arr or spatie/laravel-array.Arr, Str, and Collection—introducing Hyperf’s versions adds cognitive load.hyperf/stdlib is not designed for Laravel and offers no unique advantages over:
Arr, Str, Collection, Json).spatie/laravel-array (advanced array operations).nunomaduro/collision (string manipulation).laravelcollective/html (HTML helpers).symfony/string, symfony/collection.php-array, php-string functions or league/array-utils.hyperf/stdlib entirely. Instead:
spatie/laravel-array.nunomaduro/collision.Illuminate\Support helpers via:
array_* functions).hyperf/stdlib and Laravel are fundamentally incompatible due to:
hyperf/stdlib’s Collection lacks Laravel’s when(), tap() methods).HyperfArr that delegates to hyperf/stdlib, but this is not recommended due to performance and maintenance costs.new \Hyperf\Stdlib\Arr()), but this breaks Laravel’s service container and testing patterns.| Phase | Action | Tools/Metrics |
|---|---|---|
| Assessment | Audit custom utilities vs. Laravel’s native tools. | grep -r "array_" --include="*.php" |
| Replacement | Replace custom helpers with Laravel packages (e.g., spatie/laravel-array). |
Composer updates, unit tests. |
| Standardization | Enforce Laravel helpers via CI (e.g., block array_merge_recursive). |
PHPStan, custom lint rules. |
| Deprecation | Phase out custom utilities with @deprecated tags. |
Code coverage reports. |
hyperf/stdlib into Laravel would:
Arr::get() (Laravel) and Hyperf\Stdlib\Arr::get().stdlib reduces boilerplate, Laravel already has mature, optimized utilities.Arr, Str, and Collection to behave as documented in Laravel’s guides. Hyperf’s versions may:
Collection::when()).hyperf/stdlib may return Hyperf\Collection instead of Illuminate\Support\Collection).HyperfArr::pluck() instead of Arr::pluck()").How can I help you explore Laravel packages today?