illuminate/macroable (used for fluent method macros) to Hyperf, a high-performance PHP framework. If the team is migrating from Laravel to Hyperf or adopting Hyperf for performance-critical microservices, this package provides a familiar abstraction layer for method macros, reducing cognitive friction.Macroable), requiring minimal boilerplate to integrate into existing Hyperf classes (e.g., services, DTOs, or custom collections).v3.1.x for production until beta stabilizes.data_get), but dynamic method calls may trigger autoloading delays in large codebases.Container::get() vs. Laravel’s app().hyperf/aop replace macros?illuminate/macroable (Laravel’s original) viable for Hyperf via polyfills?Collection::macro(), Str::macro()).Collection → Hyperf\Collection or custom implementations).Macroable into utility classes (e.g., custom DTOs, helpers).Container bindings for macro registration.make:command or make:middleware to scaffold macro-enabled classes.| Feature | Laravel macroable |
Hyperf macroable |
Notes |
|---|---|---|---|
| Class Macros | ✅ | ✅ | Identical syntax. |
| Static Macros | ✅ | ✅ | Works via static::macro(). |
| Container Macros | ✅ (via app()) |
⚠️ (via Container) |
Hyperf uses Container::get() instead. |
| Macro Events | ✅ (Macroable::macro) |
❌ | Hyperf lacks Laravel’s event system. |
| Macro Removal | ✅ (macroable()->forget()) |
✅ | Same API. |
| PSR-15 Middleware Macros | ❌ | ✅ | Hyperf’s middleware pipeline supports it. |
hyperf/macroable to composer.json and bootstrapping.Macroable trait in core utility classes (e.g., App\Helpers\StringHelper).Container bindings.Str::macro() → custom StringHelper).user()->withTrashed()->macroCall()).Container may not persist across worker processes (Hyperf’s process model).go()) require careful handling of shared state.data_get under the hood; minimal impact unless thousands of macros are registered.How can I help you explore Laravel packages today?