laravel/ranger
Beta Laravel introspection library that walks your codebase and exposes rich DTOs for routes, models, enums, broadcast events, env vars, and Inertia components. Register callbacks per item or collection, then run a single walk to process everything.
ClassResult to ClassLikeResult in v0.2.5 suggests expanded support for non-class entities (e.g., traits, interfaces, or anonymous classes) while maintaining backward compatibility. This aligns with Laravel’s evolving type system (e.g., PHP 8.2+ features) and could enable:
ClassLikeResult abstraction hints at future non-Eloquent support (e.g., Livewire components, Spatie macros).onModel() callback architecture, so teams can still override or extend behavior (e.g., filtering traits).ClassResult will continue to work without updates.| Risk Area | Mitigation Strategy |
|---|---|
| Beta API Instability | Continue isolating Ranger in a feature branch or micro-service. Monitor for v1.0.0. |
| Non-Backward Compatibility | None—this is an internal refactor. Test with instanceof checks if using reflection on ClassLikeResult. |
| Performance Impact | No changes to reflection logic; no action required. |
| Future Deprecations | Watch for public API changes in ClassLikeResult (e.g., new methods for traits). |
ClassLikeResult enable new introspection targets (e.g., Livewire components, Spatie macros) in future releases?ClassLikeResult?ReflectionClass or Rector handle similar use cases without Ranger’s abstraction?$hidden/$visible are critical.ClassLikeResult refactor paves the way for future support of:
composer.json to laravel/ranger:^0.2.5 in staging.php artisan ranger:walk and verify no regression in output.v0.2.5 as a drop-in replacement (no code changes needed).ClassLikeResult exposes relevant data.- name: Validate Ranger Integration
run: |
php artisan ranger:walk --output=docs/models.json
# Add assertion to ensure no breaking changes in DTO structure
| Component | Compatibility Notes |
|---|---|
| Eloquent Models | Unchanged—full support for $hidden, $visible, $appends. |
| Custom Accessors | No impact—Ranger still reflects properties, not methods. |
| Class-Like Entities | Future potential: ClassLikeResult may enable trait/interfaces introspection. |
| Legacy Laravel | Still requires Laravel 10+ (no regression). |
| PHP 8.1+ | Required for enum support (unchanged). |
composer.json:
"require": {
"laravel/ranger": "^0.2.5"
}
composer update laravel/ranger --with-all-dependencies
ClassLikeResult doesn’t break existing workflows:
$ranger->walk()->models()->each(fn($model) => $model->class()); // Should still work
ClassLikeResult (if any are added in future).^0.2.5 in composer.json:
"require": {
"laravel/ranger": "^0.2.5"
}
onModel() callbacks remain compatible.tap() to inspect ClassLikeResult (if exploring new features):
$ranger->onModel(fn($model) => tap($model->class(), fn($class) => logger()->debug(get_class($class))));
$ranger->setDebug(true);
ClassLikeResult usage.cache()->remember('ranger:models', now()->addHours(1), fn() => $ranger->walk()->models());
ClassLikeResult behavior if future releases expose new methods.NO_UPDATE_NEEDED would not apply here—this release warrants an updated assessment due to the architectural refactor (ClassResult → ClassLikeResult) and its potential implications for future non-Eloquent support. The above is the fully updated assessment.
How can I help you explore Laravel packages today?