Skip to content

feat(php): add filesystem walk-up detection for Laravel & WordPress + structured logging#44

Merged
doITmagic merged 3 commits intodevfrom
feat/php-framework-filesystem-detection
Mar 16, 2026
Merged

feat(php): add filesystem walk-up detection for Laravel & WordPress + structured logging#44
doITmagic merged 3 commits intodevfrom
feat/php-framework-filesystem-detection

Conversation

@doITmagic
Copy link
Owner

Description

Implements filesystem-based framework detection by walking UP parent directories, replacing the previous approach that only checked the immediate file/directory level. This dramatically improves detection accuracy for deeply nested PHP files in both Laravel and WordPress projects.

  • Laravel: Walk UP parent directories looking for artisan or composer.json containing laravel/framework dependency. Results are cached via laravelCache to avoid repeated os.Stat calls across files in the same project.
  • WordPress: Walk UP parent directories looking for wp-config.php, wp-content, wp-includes, wp-admin, or plugin/theme headers (Plugin Name:, Theme Name: in style.css). Results are cached via wordpressCache.
  • Structured Logging: Replaced all fmt.Fprintf(os.Stderr, ...) calls with logger.Instance.{Debug,Info,Warn,Error} throughout the PHP parser pipeline, adding detailed enrichment pipeline logging (chunks before/after, route files, enricher applicability).
  • Version Bump: Bumped version to 2.1.86.

Key Changes & Impact:

  • pkg/parser/php/analyzer.go — Laravel walk-up detection with isLaravelByFilesystem() + laravelCache
  • pkg/parser/php/laravel/enricher.go — Structured logging for enrichment pipeline (route files, migrations, chunk counts)
  • pkg/parser/php/wordpress/analyzer.go — WordPress walk-up detection with isWordPressByFilesystem()
  • pkg/parser/php/wordpress/enricher.go — Structured logging for WordPress enrichment
  • pkg/parser/php/php_analyzer.go — Logging for enricher applicability and chunk enrichment flow

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have formatted my code with go fmt ./...
  • I have run tests go test ./... and they pass
  • I have verified integration with Ollama/Qdrant (if applicable)
  • I have updated the documentation accordingly

razvan added 2 commits March 15, 2026 21:23
… structured logging

- Laravel: walk UP parent directories looking for artisan / composer.json with laravel/framework
- WordPress: walk UP parent directories looking for wp-config.php, wp-content, plugin/theme headers
- Add detection caching (laravelCache, wordpressCache) to avoid repeated stat calls
- Replace all fmt.Fprintf(os.Stderr) with logger.Instance.{Debug,Info,Warn,Error}
- Add detailed enrichment pipeline logging (chunks before/after, route files, etc.)
- Bump version to 2.1.86
Copilot AI review requested due to automatic review settings March 15, 2026 20:24
@doITmagic doITmagic self-assigned this Mar 15, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds filesystem “walk-up” framework detection to the PHP pipeline to better classify deeply nested files as Laravel/WordPress projects, and replaces stderr printing with the repo’s structured logger.

Changes:

  • Implement WordPress parent-directory detection via isWordPressByFilesystem() and integrate it into IsWordPressProject.
  • Add Laravel parent-directory detection via IsLaravelProjectByPaths()/isLaravelRoot() and extend php.CodeAnalyzer.IsLaravelProject() with filesystem checks + caching.
  • Replace various fmt.Fprintf(os.Stderr, ...) calls with logger.Instance.{Debug,Info,Warn,Error}; bump version to 2.1.86.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
pkg/parser/php/wordpress/enricher.go Adds structured logging around WordPress enrichment flow.
pkg/parser/php/wordpress/analyzer.go Adds upward filesystem walk WordPress detection helper and calls it from IsWordPressProject.
pkg/parser/php/php_analyzer.go Adds structured logging for enricher registration/applicability/enrichment and route fallback.
pkg/parser/php/laravel/routes.go Switches route analysis error output to structured logging.
pkg/parser/php/laravel/migrations.go Switches migration analysis error output to structured logging.
pkg/parser/php/laravel/enricher.go Adds Laravel parent-directory walk-up detection and logs enrichment steps.
pkg/parser/php/analyzer.go Adds framework detection caches; extends Laravel detection with filesystem walk-up + logging.
cmd/rag-code-mcp/main.go Version bump to 2.1.86.

You can also share your feedback on Copilot code review. Take the survey.

- Add maxWalkUpDepth=10 to WordPress and Laravel filesystem walk-up detection
- Read only first 4KB of files for WP plugin/theme header checks (readFilePrefix)
- Downgrade per-file/per-enricher logs from Info to Debug to reduce noise
- Remove unused wordpressCache field from CodeAnalyzer
- Fix isLaravelByFilesystem caching to cache starting directory results
- Clarify duplicate walk-up in Laravel IsApplicable (fallback for empty packages)
- Add 8 unit tests for WordPress filesystem walk-up detection
- Add 8 unit tests for Laravel filesystem walk-up detection
@doITmagic doITmagic merged commit ae547cd into dev Mar 16, 2026
5 checks passed
@doITmagic doITmagic deleted the feat/php-framework-filesystem-detection branch March 16, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants