# Does code-review-graph Support Laravel Framework-Specific Parsing?

> Explore code-review-graph's Laravel support. Discover how it parses Blade views, service container calls, and autoloading for enhanced code analysis. Get started today!

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-08-13

---

**Yes, code-review-graph includes built-in framework-specific parsing for Laravel, automatically recognizing Blade views, service container calls, and Composer-based autoloading as first-class entities in the knowledge graph.**

code-review-graph is an open-source tool that transforms codebases into queryable knowledge graphs. For PHP developers working with the Laravel framework, the library offers framework-specific parsing capabilities that understand Laravel semantic constructs, enabling precise analysis of controller-view relationships and dependency injection.

## Framework-Specific Parsing Capabilities

The library treats Laravel as a native citizen in its parsing pipeline. When analyzing a Laravel project, code-review-graph identifies three critical framework constructs:

- **Blade Templates**: Recognizes [`.blade.php`](https://github.com/tirth8205/code-review-graph/blob/main/.blade.php) files and maps their relationships to PHP controllers
- **Service Container Bindings**: Captures Laravel's dependency injection patterns and IoC container resolutions  
- **Composer Autoloading**: Resolves class names through Laravel's PSR-4 autoloading configuration

This framework-specific awareness allows the graph to represent semantic connections that generic PHP parsers would miss, such as which controllers render specific Blade views or how services are bound in the container.

## Implementation Details

The Laravel support is implemented across three key modules in the repository:

### Parser Module ([`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py))

The central parsing logic resides in [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py), which contains explicit handling for Laravel semantic elements. According to the source code, the module includes the comment `# PHP / Laravel semantic constructs` that triggers specialized parsing rules when the detector identifies a Laravel project structure via [`composer.json`](https://github.com/tirth8205/code-review-graph/blob/main/composer.json) and typical directory layouts.

### Incremental Analysis ([`code_review_graph/incremental.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/incremental.py))

For large Laravel applications, [`code_review_graph/incremental.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/incremental.py) manages framework-specific incremental updates. This module references Laravel-related patterns such as `vendor/` directory handling, ensuring that updates to service providers or Blade templates trigger targeted re-parsing without unnecessary reprocessing of third-party dependencies.

### Test Coverage ([`tests/test_php_laravel.py`](https://github.com/tirth8205/code-review-graph/blob/main/tests/test_php_laravel.py))

The framework-specific parsing is validated in [`tests/test_php_laravel.py`](https://github.com/tirth8205/code-review-graph/blob/main/tests/test_php_laravel.py), which contains the dedicated Laravel test suite. This file exercises the parser against real Laravel project structures, confirming that Blade view resolution and service container analysis function correctly.

## Working with Laravel Projects

You can leverage Laravel-specific parsing through both the Python API and the command-line interface.

### Python API Usage

To analyze a Laravel application programmatically, import the `build_graph` function from the main module:

```python

# Example: Building a graph for a Laravel project

from code_review_graph.main import build_graph

# Path to the root of a Laravel application

laravel_root = "/path/to/laravel/project"

# Build the graph – Laravel-specific parsing is enabled automatically

graph = build_graph(laravel_root)

# Query for a Blade view and its associated controller

view_nodes = graph.search_nodes(kind="blade_view")
for view in view_nodes:
    print(f"View: {view.name}")
    for ctrl in view.related(kind="php_class"):
        print(f"  Used by controller: {ctrl.name}")

```

The `build_graph()` function automatically detects Laravel projects and applies the specialized parser rules without requiring additional configuration flags.

### Command Line Interface

For CLI workflows, the tool detects Laravel frameworks automatically:

```bash

# CLI usage: generate a graph for a Laravel app

code-review-graph build /path/to/laravel/project --output graph.json

```

The CLI inspects [`composer.json`](https://github.com/tirth8205/code-review-graph/blob/main/composer.json) and the directory structure to trigger Laravel-specific parsing, outputting a JSON graph that includes `blade_view` nodes and service container relationships alongside standard PHP class definitions.

## Summary

- code-review-graph provides native Laravel framework-specific parsing that handles Blade templates, service container bindings, and Composer autoloading as first-class graph entities.
- The implementation spans [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py) for core parsing, [`code_review_graph/incremental.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/incremental.py) for optimized rebuilds, and [`tests/test_php_laravel.py`](https://github.com/tirth8205/code-review-graph/blob/main/tests/test_php_laravel.py) for validation.
- Both the Python API (`build_graph()`) and CLI (`code-review-graph build`) automatically detect Laravel projects and apply specialized parsing rules.
- Framework awareness enables accurate mapping of controller-to-view relationships and dependency injection patterns that generic PHP parsers cannot capture.

## Frequently Asked Questions

### How does code-review-graph detect that a project is a Laravel application?

The parser examines [`composer.json`](https://github.com/tirth8205/code-review-graph/blob/main/composer.json) for Laravel framework dependencies and checks for typical directory structures such as the `app/`, `config/`, and `resources/views/` directories. When these markers are present, the parser activates the Laravel semantic construct rules defined in [`code_review_graph/parser.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/parser.py).

### Can code-review-graph resolve relationships between Blade views and their controllers?

Yes. The graph generator creates `blade_view` nodes for all [`.blade.php`](https://github.com/tirth8205/code-review-graph/blob/main/.blade.php) files and establishes relationship edges to the PHP classes that reference them in `return view()` statements. You can query these connections using `graph.search_nodes(kind="blade_view")` and traverse to related controllers via the `related()` method.

### Does the incremental analysis support Laravel's vendor directory?

Yes. [`code_review_graph/incremental.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/incremental.py) specifically recognizes Laravel's `vendor/` directory patterns and understands when to re-parse service providers versus third-party packages. This ensures that changes to your application's service bindings trigger appropriate graph updates without unnecessarily reprocessing installed dependencies.

### Is Laravel parsing available in the CLI tool without extra configuration?

Yes. The CLI automatically enables Laravel-specific parsing when it detects a Laravel project structure. Simply run `code-review-graph build /path/to/project` and the tool will handle framework detection, Blade template parsing, and service container analysis automatically.