GitAuto Logo
  1. Home
  2. Pricing
  3. Docs
  4. Dashboard
  5. Blog
  6. Contact
  1. Home
  2. How It Works
  3. Use Cases
  4. Pricing
  5. Docs
  6. Dashboard
  7. FAQ
  8. Blog
  9. Contact

PHP Coverage

Framework Configuration (All Projects)

Key Requirements

  • Coverage report must be in LCOV format
  • Report must be saved as coverage/lcov.info
  • Report must be uploaded as a GitHub Actions artifact named coverage-report

PHPUnit is the most widely used testing framework for PHP and supports generating coverage reports in various formats. While PHPUnit generates Clover XML format by default, you can convert it to LCOV format for GitAuto compatibility.

Composer Configuration (Generic PHP Projects)

composer.json
{
  "require-dev": {
    "phpunit/phpunit": "^12.0"
  },
  "scripts": {
    "test": "phpunit"
  }
}

Composer Configuration (Laravel Projects)

If you're using Laravel, use this composer.json configuration instead:

composer.json
{
  "require-dev": {
    "phpunit/phpunit": "^12.0"
  },
  "scripts": {
    "test": [
      "@php artisan config:clear --ansi",
      "@php artisan test"
    ]
  }
}

PHPUnit Configuration (All Projects)

This configuration applies to both generic PHP and Laravel projects:

phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
         bootstrap="vendor/autoload.php">
    <testsuites>
        <testsuite name="Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
    <coverage>
        <include>
            <directory suffix=".php">src</directory>
        </include>
        <report>
            <clover outputFile="coverage/clover.xml"/>
        </report>
    </coverage>
</phpunit>

Setting Up GitHub Actions

Create a workflow file in .github/workflows/ directory. The filename can be anything you prefer (e.g. php-coverage.yml). Add the following content to your workflow file:

php-coverage.yml
name: PHPUnit Coverage

# Run on target branch (probably default branch like main) to track coverage history
on:
  push:
    branches:
      - main
    # Optional: Only run when relevant files change (customize as needed)
    paths:
      - '**/*.php'
      - composer.json
      - composer.lock
      - phpunit.xml
  pull_request:
    branches:
      - main
    paths:
      - '**/*.php'
      - composer.json
      - composer.lock
      - phpunit.xml
      - '!.github/workflows/**'
  workflow_dispatch:

# Auto-cancel outdated runs on the same branch
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  cancel-in-progress: true

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      # Use Xdebug for comprehensive coverage (line, branch, path)
      # PCOV is faster but only supports line coverage
      - name: Set up PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'
          coverage: xdebug

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

      # PR: tests only, Push: tests with coverage
      # For generic PHP: runs 'phpunit' which reads phpunit.xml
      # For Laravel: runs 'php artisan test' which internally calls PHPUnit
      - name: Run tests
        if: github.event_name == 'pull_request'
        run: composer test

      # Both generate coverage because phpunit.xml configures it
      - name: Run tests with coverage
        if: github.event_name == 'push'
        run: composer test

      # Most popular Clover-to-LCOV conversion tool
      - name: Convert Clover to LCOV format
        if: github.event_name == 'push'
        uses: andstor/clover2lcov-action@v1
        with:
          src: coverage/clover.xml
          dst: coverage/lcov.info

      - name: Upload coverage reports
        if: github.event_name == 'push'
        uses: actions/upload-artifact@v6
        with:
          name: coverage-report
          path: coverage/lcov.info

Key Configuration Points

  • Configure PHPUnit to generate Clover XML coverage reports (All Projects)
  • Set up Xdebug or PCOV for code coverage (All Projects)
  • Upload the report as an artifact - name must be either coverage-report or end with lcov.info (All Projects)
  • Ensure the artifact contains coverage/lcov.info file (All Projects)

Why !.github/workflows/** on PRs Only?

On pull requests, we exclude workflow file changes to keep the setup PR minimal. When you're adding or editing a workflow file, pre-existing test failures in your codebase are irrelevant and shouldn't block the PR. On push(after merge to main), we don't exclude them so that the initial coverage report gets generated on your target branch.

Viewing Coverage Reports

After your workflow runs successfully, GitAuto automatically processes the coverage reports and displays them in the Coverage Dashboard. GitAuto only saves coverage data when the workflow runs on your target branch (configurable in your repository's Rules page, defaults to your repository's default branch, e.g., main or master). This typically happens when:

  • You merge a pull request to your target branch
  • You push directly to your target branch
  • You manually trigger the workflow

About LCOV:LCOV (Linux Code Coverage) is a standard format for code coverage data. It's pronounced "el-cov" and is widely supported by various tools and services.

Using multiple languages? If your repository has multiple programming languages (the docs use PHP + JavaScript as an example, but any combination works), see our Multi-Language Coverage guide for setting up coverage across all languages.

PHPUnit Coverage Mysteries?

PHP coverage can be tricky with Xdebug, memory limits, and configuration quirks. Whether PHPUnit is running slow, coverage is incomplete, or GitHub Actions are failing, we're here to help!

Contact us and let's debug this together!

Coverage OverviewCoverage Charts

Getting Started

  • Installation
  • Setup

Triggers

  • Overview
  • Schedule Trigger
  • Test Failure Trigger
  • Review Comment Trigger
  • Dashboard Trigger

Coverage Dashboard

  • Overview
  • Python Testing
  • JavaScript Testing
  • Java Testing
  • Go Testing
  • PHP Testing
  • Ruby Testing
  • Flutter Testing
  • Multi-Language
  • Coverage Charts

Customization

  • Repository Rules
  • Output Language
  • GITAUTO.md

Integrations

  • CircleCI Integration
  • npm Integration

How It Works

Context Enrichment

  • Line Numbers
  • Full File Reads
  • Test File Preloading
  • Test Naming Detection
  • Error Baselines
  • CI Log Cleaning
  • Trigger-Specific Prompts
  • Coding Standards

Output Auto-Correction

  • Diff Hunk Repair
  • Diff Prefix Repair
  • Tool Name Correction
  • Tool Argument Correction
  • Import Sorting
  • Trailing Space Removal
  • Final Newline
  • Line Ending Preservation
  • Sanitize Tool Arguments
  • Lint Disable Headers

Quality Verification

  • Formatting
  • Linting
  • Type Checking
  • Test Execution
  • Coverage Enforcement
  • phpcs / phpstan Support
  • PHPUnit Support
  • pytest Support
  • Snapshot Auto-Update
  • Untestable Detection
  • Should-Skip Detection
  • Dead Code Removal
  • Quality Check Scoring
  • Quality Checklist

Safety Guardrails

  • File Edit Restrictions
  • Temperature Zero
  • PR/Branch Checks
  • Race Condition Prevention
  • Bot Loop Prevention
  • Webhook Deduplication
  • Duplicate Error Hashing
  • Infrastructure Failure Detection
  • Strict Tool Schemas
  • No-Change Detection

Token/Cost Management

  • Token Trimming
  • Outdated Diff Removal
  • Stale File Replacement
  • Skip CI Intermediate
  • CI Log Deduplication
  • Web Fetch Summarization
  • Context Forgetting
  • File Query Routing
  • On-Demand Diff

Resilience & Recovery

  • Model Fallback
  • Overload Retry
  • Forced Verification
  • Error Files Editable

Hallucination Prevention

  • Web Search
  • URL Fetching
  • Anti-Hallucination Prompts
  • GITAUTO.md Restrictions
  • Review Response Guardrails

Ready to improve your test coverage?

Go from 0% to 90% test coverage with GitAuto. Start for free, no credit card required.

Install FreeContact Sales

Product

  • Home
  • Why GitAuto
  • What GitAuto Does
  • How It Works
  • Use Cases
  • How to Get Started
  • Solution
  • Pricing
  • Pricing Details
  • ROI Calculator
  • ROI Methodology
  • FAQ
  • Blog
  • Contact

Dashboard

  • Dashboard
  • Coverage Trends
  • File Coverage
  • Credits
  • Open PRs
  • Usage
  • Triggers
  • Actions
  • References
  • Rules
  • CircleCI Integration
  • npm Integration

Documentation

  • Docs
  • Getting Started
  • Setup
  • Triggers
  • Coverage Setup
  • Customization
  • How It Works
  • Auto Merge
  • CircleCI
  • npm

Legal

  • Privacy Policy
  • Terms of Service

Connect

  • GitHub
  • LinkedIn
  • Twitter
  • YouTube
GitAuto Logo© 2026 GitAuto, Inc. All Rights Reserved