feat(laravel): add Blade Template (.blade.php) semantic indexing#45
feat(laravel): add Blade Template (.blade.php) semantic indexing#45
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Laravel Blade (.blade.php) semantic indexing to make Blade templates and directives discoverable in semantic search/code graph, integrated into the existing PHP→Laravel enricher pipeline.
Changes:
- Introduces a regex-based
BladeAnalyzerto extract key Blade directives and template metadata. - Discovers
.blade.phpfiles and converts parsed templates intophp.CodeChunkentries with relations/metadata. - Integrates Blade analysis into the Laravel
Enrich()pipeline and adds unit tests + new Laravel types.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/php/laravel/blade.go | New Blade directive analyzer + view-name/path helpers |
| pkg/parser/php/laravel/blade_test.go | Unit tests for directive extraction and view-name conversion |
| pkg/parser/php/laravel/types.go | Adds Blade-related types and BladeTemplates to LaravelInfo |
| pkg/parser/php/laravel/adapter.go | Adds Blade file discovery + conversion to CodeChunk with relations/metadata |
| pkg/parser/php/laravel/enricher.go | Runs Blade analysis during Laravel enrichment and appends Blade chunks |
You can also share your feedback on Copilot code review. Take the survey.
Review Comments AddressedAll 3 Copilot review comments have been fixed: 1. ✅ Regex patterns — capture only first quoted argument (
|
- Fix regex patterns: changed (.+?) to ([^'"]+) to capture only the first quoted argument in multi-arg directives like @section('title', 'Dashboard') - Add EndLine to blade CodeChunks via new BladeTemplate.TotalLines field - Fix misleading 'Enrich DONE' log that appeared before blade analysis - Strengthen tests with value assertions (section names, view names, TotalLines)
✅ All Review Threads Verified as ResolvedVerified all 3 Copilot review comments against current codebase on 1. ✅ EndLine populated (
|
…dexing # Conflicts: # pkg/parser/php/laravel/adapter.go # pkg/parser/php/laravel/blade.go # pkg/parser/php/laravel/enricher.go # pkg/parser/php/laravel/types.go
There was a problem hiding this comment.
Pull request overview
Adds Laravel Blade (.blade.php) semantic indexing to the existing PHP→Laravel enrichment pipeline so Blade directives become searchable symbols/relations in the code graph.
Changes:
- Introduces a regex-based
BladeAnalyzerto extract key Blade directives intoBladeTemplatestructures. - Discovers
.blade.phpfiles and converts extracted directives intophp.CodeChunkentries with relations/metadata. - Integrates Blade enrichment into
Enrich()and adds unit tests + Laravel types for Blade templates.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/php/laravel/blade.go | Blade directive regex extraction + template metadata (name, lines, directives). |
| pkg/parser/php/laravel/blade_test.go | Tests for directive extraction correctness and edge cases. |
| pkg/parser/php/laravel/types.go | Adds Blade-related types and includes them in LaravelInfo. |
| pkg/parser/php/laravel/adapter.go | Discovers Blade files + converts templates into CodeChunk relations/metadata. |
| pkg/parser/php/laravel/enricher.go | Hooks Blade analysis into the Laravel enrich pipeline. |
You can also share your feedback on Copilot code review. Take the survey.
| reExtends = regexp.MustCompile(`@extends\(\s*['"]([^'"]+)['"]`) | ||
| reSection = regexp.MustCompile(`@section\(\s*['"]([^'"]+)['"]`) | ||
| reYield = regexp.MustCompile(`@yield\(\s*['"]([^'"]+)['"]`) | ||
| reInclude = regexp.MustCompile(`@include\(\s*['"]([^'"]+)['"]`) | ||
| reComponent = regexp.MustCompile(`@component\(\s*['"]([^'"]+)['"]`) | ||
| reEach = regexp.MustCompile(`@each\(\s*['"]([^'"]+)['"]`) | ||
| rePushStack = regexp.MustCompile(`@(?:push|stack)\(\s*['"]([^'"]+)['"]`) |
Description
Add semantic indexing for Laravel Blade templates (
.blade.php), extracting structural directives as symbols with inheritance and dependency relations in the Code Graph.Previously,
.blade.phpfiles were accepted by the PHP parser (CanHandle()returnstruefor anything ending in.php), but only PHP constructs (classes, functions) were extracted. All Blade-specific directives (@extends,@section,@yield,@include,@component, etc.) were completely ignored, making Blade templates invisible to semantic search.What this adds:
@extends→ inheritance relations@section/@yield→ section symbols@include/@component/@each→ dependency relations@push/@stack→ stack tracking@props→ component property extractionfindBladeFiles()— recursive.blade.phpfile discovery with vendor/node_modules exclusionconvertBladeToChunks()— converts templates toCodeChunkwith:blade_templateRelInheritancefor@extends,RelDependencyfor@include/@component)Enrich()pipeline — follows the sameFrameworkEnricherpattern as Routes/Eloquent/MigrationsbladeViewName()— converts file paths to Laravel dot notation (e.g.,resources/views/layouts/app.blade.php→layouts.app)BladeTemplate,BladeSection,BladeIncludeintypes.goArchitecture decision:
Implemented as a Laravel enricher extension (not a separate parser), because:
.blade.phpalready passes PHPCanHandle()— no new parser registration neededpkg/parser/php/laravel/FrameworkEnricherpattern used by Routes/Eloquent/MigrationsCloses: Trello cards #104-#111
Type of change
Checklist:
go fmt ./...go test ./...and they passFiles Changed
pkg/parser/php/laravel/blade.gopkg/parser/php/laravel/blade_test.gopkg/parser/php/laravel/types.goBladeTemplate,BladeSection,BladeIncludetypes +BladeTemplatesfield inLaravelInfopkg/parser/php/laravel/adapter.gofindBladeFiles()+convertBladeToChunks()pkg/parser/php/laravel/enricher.goEnrich()pipeline