Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ranger Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Ranger is a powerful introspection library for Laravel applications.

Frequently asked questions about Ranger
What’s the best use case for Laravel Ranger in a large-scale Laravel app?
Ranger excels at generating dynamic documentation, API contracts (e.g., OpenAPI), or compliance checks by scanning routes, models, and enums into structured DTOs. For example, use it to auto-generate Swagger specs from your route definitions or validate model attributes against business rules.
How do I install and run Ranger in a Laravel 11 project?
Run `composer require laravel/ranger` and initialize it via the service container: `$ranger = app(Ranger::class);`. Register callbacks (e.g., `onRoute()` or `onModels()`) and call `$ranger->walk()` to trigger introspection. No migrations or config files are required.
Can Ranger handle sensitive data like .env variables or route middleware?
Ranger collects raw data, including environment variables and middleware, but you must sanitize outputs if exposing them (e.g., in public docs). Use callbacks to filter or transform sensitive data before processing or storage.
What Laravel versions does Ranger support, and are there compatibility risks?
Ranger officially supports Laravel 10–13. Laravel 9 may work but lacks testing; use polyfills like `ShouldBroadcastNow` if needed. Since it’s beta, pin to a specific version (e.g., `0.1.12`) in `composer.json` to avoid breaking changes pre-v1.0.0.
How can I optimize performance for large codebases with thousands of routes/models?
Introspection is CPU-intensive. Mitigate this by running `walk()` asynchronously (e.g., via Laravel Queues or cron), caching results in Redis, or excluding irrelevant paths (e.g., `vendor/`, `tests/`). Test with a staging-like environment to measure runtime.
Does Ranger support custom collectors for non-standard Laravel components?
Yes, Ranger’s extensible design allows you to create custom collectors for niche components. Extend the base `Collector` class, register it via `$ranger->extend()`, and implement logic to scan your specific files or classes.
How do I handle API changes in Ranger’s beta phase?
Wrap callbacks in version checks or feature flags to gracefully handle breaking changes. Monitor the [changelog](https://github.com/laravel/ranger/blob/main/CHANGELOG.md) and plan for upgrades post-v1.0.0. Consider testing with a dev branch before production rollouts.
Can Ranger integrate with Inertia.js or Livewire for frontend component discovery?
Yes, Ranger natively supports Inertia.js components (v1.x) and can discover their props, pages, and layouts. For Livewire, you’d need a custom collector to scan `.blade.php` files or Livewire class annotations, as it’s not built-in.
What alternatives exist for Laravel code introspection if Ranger isn’t stable enough?
For static analysis, consider `phpDocumentor` (general PHP) or `Laravel IDE Helper` (for IDE autocompletion). For runtime introspection, use Laravel’s built-in tools like `Route::getRoutes()`, `Schema::getColumnListing()`, or third-party packages like `spatie/laravel-activitylog` for event tracking.
How can I test Ranger’s output before using it in production?
Start by logging DTOs to a file or console during `walk()` to validate data quality. Use a subset of collectors (e.g., only routes or models) in a non-production environment. Gradually add write operations (e.g., database updates) once you’re confident in the output.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai