Documentation

blight is a PHP CLI tool that detects version and environment drift between your local machine and CI/CD environments. Run one command to know exactly why your local build passes but CI fails.

Introduction

Most CI failures caused by environment mismatch are invisible until they hit the build server. blight compares your local environment against GitHub Actions logs in real time — surfacing PHP version mismatches, missing Node.js, and ENV variable drift before you push.

Installation

Clone and run locally

bash
git clone https://github.com/blight-dev/blight.git
cd blight
composer install
php bin/blight --version

Composer global install (once on Packagist)

composer global require blight/blight
blight --version
Make sure your Composer global bin directory is in your $PATH: export PATH="$HOME/.composer/vendor/bin:$PATH"

Requirements: PHP 8.2+, Composer 2.x, ext-json

Quick Start

The fastest way to catch a CI mismatch:

1. Check your local environment
php bin/blight info
2. Parse a CI log file
php bin/blight parse --log /path/to/github-actions.log
3. Compare local vs CI
php bin/blight compare --log /path/to/github-actions.log
4. See a full summary report
php bin/blight report

blight info

Syntax
blight info [options]

Display your local environment: PHP version, SAPI, Node.js, npm, OS, architecture, Git branch/commit, and ENV variables (sensitive values auto-redacted).

OptionDescription
--output jsonEmit machine-readable JSON instead of tables
--show-secretsReveal redacted ENV values
-v / --verboseExtended output with additional env detail
-q / --quietOne-liner summary only
Example
$ php bin/blight info
blight.dev – Local Environment Inspector
=========================================
PHP Version   8.2.0
Node Version  20.11.0
OS            Linux x86_64
Branch        main / abc1234
DATABASE_URL  [REDACTED]

blight parse

Syntax
blight parse --log <file> [options]

Parse a GitHub Actions log file. Detects CI steps, failed steps, error lines, and PHP/Node versions used in CI.

OptionDescription
--log <path>Required. Path to the CI log file
--output jsonEmit JSON result
-qOne-liner: error count summary
-vShow each error line with full context
Example
$ php bin/blight parse --log examples/ci-major-mismatch.log
Steps: Set up PHP ✓, Set up Node.js ✓, Run tests ✗
Errors (2): PHP Fatal error in Util.php:42, exit code 255
Summary: 3 steps, 1 failed, 2 errors

blight compare

Syntax
blight compare --log <file> [options]

The core command. Compares your live local environment against what was detected in the CI log. Classifies every difference as CRITICAL, WARNING, or INFO.

OptionDescription
--log <path>Required. Path to the CI log file
--output jsonEmit structured JSON with mismatches array
--repo <name>Tag analysis under a specific repo name
-qOne-liner: CRITICAL N, WARNING N, Total N
A CRITICAL mismatch means your code is very likely to fail in CI. Address these first before pushing.
Example output
┌──────────┬─────────────────┬───────────┬────────┬─────────────────────────────────────┐
│ Severity │ Key             │ Local     │ CI     │ Message                             │
├──────────┼─────────────────┼───────────┼────────┼─────────────────────────────────────┤
│ CRITICAL │ PHP Version     │ 8.2.0     │ 7.4.33 │ Major version mismatch — will fail  │
│ WARNING  │ Node.js Version │ not found │ 18.1.0 │ CI uses Node.js, not installed here │
└──────────┴─────────────────┴───────────┴────────┴─────────────────────────────────────┘

blight report

Syntax
blight report [options]

The default command (runs when you call blight with no arguments). Shows a summary of recent analyses stored in .blight_usage.json.

OptionDescription
--output jsonEmit JSON summary
-qOne-liner count of analyses

blight history Paid

Syntax
blight history [options]

Show detailed history of all past analyses, filterable by repo or severity. Full history requires a paid API key. Free plan shows the last 5 entries.

OptionDescription
--repo <name>Filter history by repository name
--severity <level>Filter by CRITICAL, WARNING, or INFO
--output jsonEmit JSON — paid only
-qOne-liner count

blight init

Syntax
blight init

Interactively create a .blight.json config file in the current directory. Sets your API key, default repo name, and alert preferences.

Example
$ php bin/blight init
? API key (leave blank for free plan): blight_pro_xxxxxxxxx
? Default repo name: my-app
? Enable Slack alerts? No
✔ Created .blight.json

Configuration — .blight.json

blight looks for a .blight.json file in the current directory. Create one with blight init or manually:

{
  "api_key": "blight_pro_xxxxxxxxxxxxxxxx",
  "repo": "my-app",
  "alerts": {
    "slack_webhook": "https://hooks.slack.com/services/...",
    "discord_webhook": ""
  }
}
.blight.json and .blight_usage.json are automatically added to .gitignore — your API key is never committed.

Output Formats

All commands support --output json for structured machine-readable output. Useful for scripting, CI integration, or dashboards.

JSON output — blight compare
{
  "command": "compare",
  "repo": "my-app",
  "timestamp": "2026-04-09T12:00:00Z",
  "mismatches": [
    {
      "severity": "CRITICAL",
      "key": "PHP Version",
      "local": "8.2.0",
      "ci": "7.4.33",
      "message": "Major PHP version mismatch"
    }
  ],
  "summary": { "critical": 1, "warning": 0, "info": 0 }
}

Quiet Mode (-q)

Pass -q to any command to get a single-line summary. Ideal for shell scripts and CI pipelines.

$ php bin/blight compare --log ci.log -q
CRITICAL: 1, WARNING: 1, Total: 2

$ php bin/blight parse --log ci.log -q
Errors: 2, Warnings: 0, Failed steps: 1

Webhook Alerts Paid

blight can send a webhook notification every time a compare finds mismatches. Supports Slack and Discord (any service accepting JSON POST).

Configure via .blight.json

{
  "api_key": "blight_pro_xxxxxxxxxxxxxxxx",
  "repo": "my-app",
  "alerts": {
    "slack_webhook": "https://hooks.slack.com/services/T.../B.../xxx",
    "discord_webhook": "https://discord.com/api/webhooks/..."
  }
}

Or pass inline with compare

php bin/blight compare --log ci.log \
  --alert slack \
  --webhook-url https://hooks.slack.com/services/...
OptionDescription
--alert slackSend mismatch summary to Slack webhook URL
--alert discordSend mismatch summary to Discord webhook URL
--webhook-url <url>Override webhook URL from config for this run
Webhooks fire only when mismatches are detected. A clean compare (no drift) sends nothing.

GitHub Actions Integration

blight ships with a ready-to-use GitHub Actions pipeline at .github/workflows/ci.yml. It runs on every push and pull request, covering lint, static analysis, and blight's own dogfood steps.

.github/workflows/ci.yml
name: CI

on:
  push:
  pull_request:

jobs:
  build:
    name: PHP ${{ matrix.php-version }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php-version: ["8.2"]

    steps:
      - uses: actions/checkout@v4

      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-version }}

      - name: Validate composer.json
        run: composer validate --strict

      - name: Cache Composer packages
        uses: actions/cache@v4
        with:
          path: vendor
          key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}

      - name: Install dependencies
        run: composer install --no-interaction --prefer-dist

      - name: Lint PHP syntax
        run: find src/ -name "*.php" -print0 | xargs -0 -n1 php -l

      - name: PHPStan static analysis
        run: vendor/bin/phpstan analyse --no-progress --error-format=github

      - name: blight — parse sample log (dogfood)
        continue-on-error: true
        run: php bin/blight parse --log examples/ci-sample.log

      - name: blight — compare local vs CI sample (dogfood)
        continue-on-error: true
        run: php bin/blight compare --log examples/ci-sample.log
The dogfood steps use continue-on-error: true because blight compare exits 1 whenever it finds drift — which is its intended behavior. This lets CI output show the mismatch report without blocking the build.

Using blight in your own CI

To use blight as a drift-detection step in any existing GitHub Actions workflow, add a step that downloads your actual CI log and runs compare:

- name: Detect environment drift with blight
  run: |
    php bin/blight compare --log "${{ runner.temp }}/ci-run.log" -q
  continue-on-error: true

Sample Log Format

blight parses GitHub Actions log files downloaded from the Actions tab of your repository. The parser looks for specific patterns:

PatternWhat blight extracts
##[group]Step nameCI step boundary
##[endgroup]Step end
##[error]...Error line (increments error count)
PHP 8.2.17 (cli)... installedPHP version used in CI
Node.js v20.11.1 installedNode.js version used in CI
Process completed with exit code NStep failure detection

The examples/ directory contains two reference logs you can use for testing:

Parse a sample log locally
php bin/blight parse --log examples/ci-sample.log
php bin/blight compare --log examples/ci-major-mismatch.log

Pre-push Git Hook

Catch CI drift before you push by wiring blight into a Git pre-push hook. Save your latest CI log and compare it automatically on every push:

.git/hooks/pre-push
#!/bin/sh
# blight pre-push hook — abort if CRITICAL drift is found
LOG="$HOME/.blight/last-ci.log"
if [ -f "$LOG" ]; then
  RESULT=$(php bin/blight compare --log "$LOG" -q 2>&1)
  echo "$RESULT"
  if echo "$RESULT" | grep -q "CRITICAL: [1-9]"; then
    echo "blight: CRITICAL environment drift detected. Fix before pushing."
    exit 1
  fi
fi
exit 0
chmod +x .git/hooks/pre-push

PHPStan Integration

blight uses PHPStan for static analysis at level 5. The configuration lives in phpstan.neon at the project root:

includes:
    - phpstan-baseline.neon

parameters:
    level: 5
    paths:
        - src/

The phpstan-baseline.neon file baselines pre-existing errors in the codebase so that only new code must be clean. To regenerate the baseline after fixing errors:

vendor/bin/phpstan analyse --generate-baseline --memory-limit=512M

PHPStan runs automatically on every push via the CI pipeline and outputs annotations directly in GitHub pull requests using --error-format=github.

Multi-Language Support

blight supports English, Turkish, and Simplified Chinese output. Set your preferred language via CLI flag, config file, or environment variable.

Usage

CLI flag (highest priority)
php bin/blight info --lang tr
php bin/blight compare --log ci.log --lang zh
Config file (.blight.json)
{
    "lang": "tr"
}
Environment variable
BLIGHT_LANG=tr php bin/blight info

Priority Order

  1. --lang CLI flag
  2. .blight.json "lang" field
  3. BLIGHT_LANG environment variable
  4. Default: en (English)

Supported Languages

CodeLanguage
enEnglish (default)
trTurkish / Türkçe
zhSimplified Chinese / 简体中文
The --lang flag is supported by all commands: info, parse, compare, report, history, and init.

Free Plan

Set your API key in .blight.json or via blight init to activate paid features.

Powered by Aden