Hamburger Cross Icon
Code Style Configured
+
PHP Collector

Code Style Configured + PHP Collector

Guardrail Collector Beta Devex Build And Ci

Enforce Code Style Configured using data collected by PHP Collector. Automatically check devex build and ci standards on every PR.

Guardrail: Ensures a code style tool (PHP-CS-Fixer or PHP_CodeSniffer) is configured. Consistent code style reduces cognitive load and merge conflicts.
Data Source: Analyze PHP projects to collect Composer metadata, dependencies, tool configuration (PHPUnit, PHPStan, Psalm, PHP-CS-Fixer, PHPCS), and CI/CD command tracking. Enforce PHP-specific engineering standards.

How PHP Collector Powers This Guardrail

The PHP Collector gathers metadata from your languages, build systems. This data flows into Lunar's Component JSON, where the Code Style Configured guardrail evaluates it against your standards.

When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.

1
PHP Collector Gathers Data Collector
Extracts metadata from code, configs, and tool outputs
2
{ } Component JSON
Data centralized in structured format for evaluation
3
Code Style Configured Checks Guardrail
Pass/fail result with actionable feedback in PRs

Quick Start Configuration

Add both the collector and policy to your lunar-config.yml to enable this guardrail.

📄 lunar-config.yml
# Step 1: Enable the PHP Collector
collectors:
  - uses: github://earthly/lunar-lib/collectors/php@v1.0.5
    # with: ...

# Step 2: Enable the PHP Project Guardrails
policies:
  - uses: github://earthly/lunar-lib/policies/php@v1.0.5
    include: [code-style-configured]
    # with: ...

What PHP Collector Collects

This collector gathers the following data that the Code Style Configured guardrail evaluates.

Collector ci-before-command

cicd

Records every PHP command executed in CI pipelines along with the PHP runtime version. Writes command strings and version info to .lang.php.cicd for audit trails and build reproducibility analysis.

Collector ci-before-command

composer-cicd

Records every Composer command executed in CI pipelines along with the Composer version. Writes command strings and version info to .lang.php.composer.cicd for audit trails and dependency management.

Collector code

project

Analyzes PHP project structure by detecting composer.json, composer.lock, vendor directory, and tool configuration (PHPUnit, PHPStan, Psalm, PHP-CS-Fixer, PHP_CodeSniffer). Extracts the PHP version constraint. Writes PHP-level metadata to .lang.php and Composer metadata to .lang.php.composer.

Collector code

dependencies

Extracts direct and dev dependencies from composer.json. Captures package name and version constraint for each dependency. Writes the dependency list to .lang.php.dependencies.

Example Data Flow

Here's an example of the data that PHP Collector writes to the Component JSON, which Code Style Configured then evaluates.

{ } component.json From PHP Collector
{
  "lang": {
    "php": {
      "version": "^8.2",
      "build_systems": ["composer"],
      "phpunit_configured": true,
      "static_analysis_configured": true,
      "static_analysis_tool": "phpstan",
      "code_style_configured": true,
      "code_style_tool": "php-cs-fixer",
      "source": { "tool": "php", "integration": "code" },
      "cicd": {
        "cmds": [
          { "cmd": "php artisan migrate", "version": "8.2.15" }
        ]
      },
      "dependencies": {
        "direct": [
          { "path": "laravel/framework", "version": "^11.0" }
        ],
        "dev": [
          { "path": "phpunit/phpunit", "version": "^11.0" }
        ],
        "source": { "tool": "composer", "integration": "code" }
      },
      "composer": {
        "json_exists": true,
        "lock_exists": true,
        "vendor_exists": false,
        "cicd": {
          "cmds": [
            { "cmd": "composer install --no-dev", "version": "2.7.1" }
          ]
        }
      }
    }
  }
}

Configuration Options

PHP Collector Inputs

Input Required Default Description

PHP Project Guardrails Inputs

Input Required Default Description
min_version Optional 8.1 Minimum required PHP version (e.g., "8.1", "8.2")
min_version_cicd Optional 8.1 Minimum required PHP CI runtime version (e.g., "8.1", "8.2")
min_composer_version Optional 2.6 Minimum required Composer version (e.g., "2.6", "2.7")

Ready to Automate Your Standards?

See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.

Works with any process
check AI agent rules & prompt files
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo