Introducing the three packages that form Laravel’s new code analysis ecosystem: surveyor, ranger, and roster. A guide for package developers and tool authors on PHP static analysis, application introspection, and package detection.
Use this file to discover all available pages before exploring further.
This article is based on the official README files and source code of each repository. All three packages are pre-release Beta versions as of April 2026.
surveyor, ranger, and roster are all currently in Beta. Their APIs are subject to change before the v1.0.0 release. Use with caution in production environments.
In 2026, Laravel released three packages centered around code analysis. While each can be used independently, they form an interconnected code analysis ecosystem.
laravel/surveyor is a powerful (mostly) static analysis tool that parses PHP files and extracts detailed metadata about classes, methods, properties, return types, and more — making this information available in a structured format for use by other tools and packages. It is “mostly” static because it does attempt a brief database connection when analyzing Eloquent models to gather richer information.
use Laravel\Surveyor\Analyzer\Analyzer;$analyzer = app(Analyzer::class);// Analyze a file by path$result = $analyzer->analyze('/path/to/your/File.php');// Access the analyzed scope$scope = $result->analyzed();// Access the class result$classResult = $result->result();
Cache analysis results to improve performance when analyzing files repeatedly.
use Laravel\Surveyor\Analyzer\AnalyzedCache;// Enable disk cachingAnalyzedCache::enableDiskCache(storage_path('surveyor-cache'));// Clear the cacheAnalyzedCache::clear();
You can also configure caching via environment variables:
Surveyor provides special support for Eloquent models, automatically detecting relationships, attributes, accessors, and cast definitions.
$result = $analyzer->analyzeClass(App\Models\User::class)->result();// Database attributes are automatically detected$emailProperty = $result->getProperty('email');// Identify relationship methods$method = $result->getMethod('posts');if ($method->isModelRelation()) { // This is a relationship method}
Surveyor attempts a brief database connection when analyzing Eloquent models, so it is not purely static analysis. Performance and memory usage are still being improved, and contributions in those areas are welcome.
laravel/ranger wraps Surveyor and provides a high-level introspection library that walks through your entire Laravel application, collecting information about routes, models, enums, broadcast events, environment variables, and Inertia.js components.
Register callbacks that fire as each component is discovered. Each callback receives a detailed DTO.
use Laravel\Ranger\Ranger;use Laravel\Ranger\Components;use Illuminate\Support\Collection;$ranger = app(Ranger::class);// Called for each route discovered$ranger->onRoute(function (Components\Route $route) { echo $route->uri();});// Called for each model discovered$ranger->onModel(function (Components\Model $model) { foreach ($model->getAttributes() as $name => $type) { // Process attribute names and types }});// Called for each enum discovered$ranger->onEnum(function (Components\Enum $enum) { //});// Called for each broadcast event discovered$ranger->onBroadcastEvent(function (Components\BroadcastEvent $event) { //});// Called once after all routes have been collected$ranger->onRoutes(function (Collection $routes) { //});// Called once after all models have been collected$ranger->onModels(function (Collection $models) { //});// Walk through the application and trigger all callbacks$ranger->walk();
laravel/roster detects which Laravel ecosystem packages are installed in a project and provides an easy-to-use API to work with that data. It is ideal for package developers and tool authors who need to know “Is this project using Inertia?” or “What version of Livewire is installed?”
use Laravel\Roster\Roster;use Laravel\Roster\Packages;// Scan a directory and get the roster$roster = Roster::scan($directory);// All installed packages$roster->packages();// Production-only packages$roster->packages()->production();// Dev-only packages$roster->packages()->dev();// Check if a specific package is installed$roster->uses(Packages::INERTIA); // bool$roster->uses(Packages::LIVEWIRE); // bool// Check with a version constraint$roster->usesVersion(Packages::INERTIA, '2.0.0', '>='); // Inertia >= 2.0.0?$roster->usesVersion(Packages::LIVEWIRE, '3.0.0', '>='); // Livewire >= 3.0.0?// Detect the JavaScript package manager in use$packageManager = $roster->nodePackageManager(); // 'npm', 'yarn', 'bun', etc.
Laravel Boost uses Roster internally to understand a project’s installed package configuration and automatically tailor the AI guidelines and skills it generates for agents like GitHub Copilot and Claude. It checks questions like “Is this project using Inertia?” and “Is Livewire installed?” to select the appropriate guideline files and provide them to the AI agent.
Ranger lets you build tools that automatically collect and document an application’s routes, models, and enums:
use Laravel\Ranger\Ranger;use Laravel\Ranger\Components;$ranger = app(Ranger::class);$docs = [];$ranger->onRoute(function (Components\Route $route) use (&$docs) { $docs['routes'][] = [ 'uri' => $route->uri(), // Validation rules and response types are also available ];});$ranger->onModel(function (Components\Model $model) use (&$docs) { $docs['models'][] = [ 'attributes' => $model->getAttributes(), ];});$ranger->walk();// $docs now contains structured information about the entire application
surveyor, ranger, and roster provide a new foundation for programmatic code analysis in the Laravel ecosystem.These packages are primarily aimed at package developers and tool authors rather than end users. However, they are already being used internally by official Laravel tools like Boost, and broader adoption across the ecosystem is expected as they mature toward v1.0.0.