Skip to main content

Documentation Index

Fetch the complete documentation index at: https://kawax.biz/llms.txt

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.

Overview

In 2026, Laravel released three packages centered around code analysis. While each can be used independently, they form an interconnected code analysis ecosystem.
PackageRoleInstallation
laravel/surveyorPHP static analysis enginecomposer require laravel/surveyor
laravel/rangerFull Laravel application introspectioncomposer require laravel/ranger
laravel/rosterEcosystem package detectioncomposer require laravel/roster --dev
Let’s look at each package in detail.

laravel/surveyor — Static Analysis Engine

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.

Installation

composer require laravel/surveyor

Basic usage

Analyzing a file

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();

Analyzing a class directly

$result = $analyzer->analyzeClass(\App\Models\User::class);
$classResult = $result->result();

Working with ClassResult

$classResult = $analyzer->analyzeClass(App\Models\User::class)->result();

// Class information
$name = $classResult->name();            // 'App\Models\User'
$namespace = $classResult->namespace();  // 'App\Models'
$filePath = $classResult->filePath();

// Inheritance
$extends = $classResult->extends();
$implements = $classResult->implements();

// Method information
$method = $classResult->getMethod('store');
$returnType = $method->returnType();
$parameters = $method->parameters();
$rules = $method->validationRules(); // Extracts validation rules from the method body

// Property information
$property = $classResult->getProperty('email');
$type = $property->type;
$visibility = $property->visibility; // 'public', 'protected', or 'private'

// All public methods and properties
$publicMethods = $classResult->publicMethods();
$publicProperties = $classResult->publicProperties();

Type system

Surveyor includes a comprehensive type system for representing PHP types.
use Laravel\Surveyor\Types\Type;

// Primitive types
$stringType = Type::string();
$intType = Type::int();
$boolType = Type::bool();
$nullType = Type::null();

// Union types (e.g. string|null)
$unionType = Type::union(Type::string(), Type::null());

// Type checking
use Laravel\Surveyor\Types\StringType;

if (Type::is($returnType, StringType::class)) {
    // Handle string return type
}

Caching

Cache analysis results to improve performance when analyzing files repeatedly.
use Laravel\Surveyor\Analyzer\AnalyzedCache;

// Enable disk caching
AnalyzedCache::enableDiskCache(storage_path('surveyor-cache'));

// Clear the cache
AnalyzedCache::clear();
You can also configure caching via environment variables:
SURVEYOR_CACHE_ENABLED=true
SURVEYOR_CACHE_DIR=/path/to/cache

Eloquent model analysis

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 — High-level Introspection

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.

Installation

composer require laravel/ranger

Basic usage

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();

What Ranger collects

CollectorDescription
RoutesAll registered routes with URIs, parameters, HTTP verbs, controllers, validation rules, and possible responses
ModelsEloquent models with their attributes, types, and relationships
EnumsPHP backed enums with their cases and values
Broadcast EventsEvents implementing ShouldBroadcast with their payloads
Broadcast ChannelsRegistered broadcast channels
Environment VariablesVariables defined in your .env file
Inertia Shared DataGlobally shared Inertia.js props
Inertia ComponentsInertia.js page components with their expected props

laravel/roster — Package Detection

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?”

Installation

composer require laravel/roster --dev

Basic usage

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.

Real-world use cases

AI guideline generation (Boost)

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.

Building a package compatibility checker

When developing a package that should behave differently depending on what the user has installed, Roster makes it easy:
use Laravel\Roster\Roster;
use Laravel\Roster\Packages;

$roster = Roster::scan(base_path());

if ($roster->uses(Packages::INERTIA)) {
    // Handle Inertia-specific logic
    if ($roster->usesVersion(Packages::INERTIA, '2.0.0', '>=')) {
        // Handle Inertia v2+ specific logic
    }
}

if ($roster->uses(Packages::LIVEWIRE)) {
    // Handle Livewire-specific logic
}

// Tailor install instructions to the detected package manager
$pm = $roster->nodePackageManager();
echo "Run: {$pm} install your-package";

Auto-generating application documentation

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

Summary

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.

laravel/surveyor

PHP static analysis engine

laravel/ranger

High-level introspection library

laravel/roster

Package detection tool
Last modified on April 14, 2026