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.
$hidden, $visible, and $appends attributes on Eloquent models, enabling richer internal developer portals (e.g., "View all non-serialized fields for this model") or IDE plugins (e.g., autocompletion for model attributes).password from API responses).$visible or sensitive fields exposed via $appends (e.g., "This model appends api_token to all responses").$appends or redundant $hidden rules during schema migrations (e.g., "This field is hidden but never accessed").$hidden/$visible.Adopt if:
$hidden, $visible, $appends) and manual tracking is error-prone.Look elsewhere if:
$hidden/$visible/$appends (this feature adds marginal value).$appends at compile-time) instead of runtime introspection."Laravel Ranger v0.2.4 now automatically maps model serialization rules ($hidden, $visible, $appends), letting us:
password, api_token) from leaking in responses or frontend props.user.ssn—but it’s hidden in the API’).$appends or redundant $hidden rules before they break integrations.
Example: Our /api/users endpoint now automatically excludes password and email_verified_at—no manual OpenAPI annotations needed. This is table stakes for modern Laravel apps and aligns with our roadmap for a self-service developer hub.""Ranger’s new model introspection lets you hook into serialization logic with callbacks like:
$ranger->onModel(fn(Model $model) => tap($model, fn($m) =>
// Log all non-serialized attributes for audit trails
logger()->info('Hidden fields:', $m->getHidden())
));
Use cases:
$visible (e.g., mobile apps vs. web).$hidden fields).$hidden (e.g., fail CI if a frontend page passes a hidden field).$appends.Pros:
created_at for guests").Cons:
Try it:
composer require laravel/ranger
$ranger = new Ranger();
$ranger->onModel(fn(Model $model) => $model->toArray()); // Get serialized data
```"
How can I help you explore Laravel packages today?