PHPackages                             itsjustvita/laravel-bfsg - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. itsjustvita/laravel-bfsg

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

itsjustvita/laravel-bfsg
========================

Laravel Package für BFSG/WCAG Barrierefreiheit Compliance

v2.2.2(1mo ago)3656MITPHPPHP ^8.2CI failing

Since Sep 19Pushed 1mo agoCompare

[ Source](https://github.com/itsjustvita/laravel-bfsg)[ Packagist](https://packagist.org/packages/itsjustvita/laravel-bfsg)[ RSS](/packages/itsjustvita-laravel-bfsg/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (10)Versions (13)Used By (0)

Laravel BFSG - Accessibility Compliance Package
===============================================

[](#laravel-bfsg---accessibility-compliance-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/781f590ad897c0a0318918a8f934bfaf657829dfe97f04287891c1b37061f6a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974736a757374766974612f6c61726176656c2d626673672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itsjustvita/laravel-bfsg)[![Total Downloads](https://camo.githubusercontent.com/f247bb2a0a0cc97debf76fcb1efd3f3d5faf36f330bbc95a36932ded84565a7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6974736a757374766974612f6c61726176656c2d626673672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itsjustvita/laravel-bfsg)[![License](https://camo.githubusercontent.com/1bd9df3683e9774d5105d7d29ef0adf3b1682a3b7255ad950f10c78bb1cf91d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6974736a757374766974612f6c61726176656c2d626673672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itsjustvita/laravel-bfsg)[![PHP Version](https://camo.githubusercontent.com/b522217e5db873aeaacc48cbac84b59541882b9db9bbd28b9a6c750da8eaf143/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6974736a757374766974612f6c61726176656c2d626673672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itsjustvita/laravel-bfsg)[![Laravel Version](https://camo.githubusercontent.com/947656787bad2f17fdd46ddf773bba151d4e29a133c447cbf6a878991426ee55/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e7825323025374325323031332e782d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://laravel.com)

A comprehensive Laravel package for BFSG (Barrierefreiheitsstärkungsgesetz) and WCAG compliance, helping developers create accessible web applications that comply with German and international accessibility standards.

Features
--------

[](#features)

- **WCAG 2.1 Level AA/AAA Compliance Checking**
- **BFSG 2025 Ready** - Full compliance with German accessibility law
- **16 Specialized Analyzers** - Images, Forms, Headings, ARIA, Links, Keyboard, Language, Tables, Media, Semantic HTML, Contrast, Page Title, Input Purpose, Focus, Error Handling, Status Messages
- **CSS-Based Contrast Analysis** - Parses `` blocks with cascade/specificity/inheritance resolution
- **MCP Server** - Built-in Model Context Protocol server for AI assistant integration (Laravel Boost compatible)
- **SPA Support** - Test React, Vue, Inertia apps with Playwright browser engine
- **HTML &amp; PDF Reports** - Professional reports with compliance scores and grades
- **Multiple Report Formats** - HTML, PDF, JSON, Markdown with statistics
- **Database Persistence** - Track violations over time with Eloquent models and publishable migrations
- **Blade Components** - Pre-built accessible components
- **Artisan Commands** - CLI tools for accessibility testing
- **Detailed Reporting** - Comprehensive violation reports with suggestions
- **Laravel 12 + 13 Support** - Built for the latest Laravel versions

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 12.0 or 13.0 or higher

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require itsjustvita/laravel-bfsg
```

Publish the configuration file:

```
php artisan vendor:publish --tag=bfsg-config
```

Optionally publish the views:

```
php artisan vendor:publish --tag=bfsg-views
```

Publish the database migrations (required for `--save` and `bfsg:history`):

```
php artisan vendor:publish --tag=bfsg-migrations
php artisan migrate
```

Configuration
-------------

[](#configuration)

The configuration file `config/bfsg.php` allows you to customize:

```
return [
    // WCAG compliance level: 'A', 'AA', or 'AAA'
    'compliance_level' => env('BFSG_LEVEL', 'AA'),

    // Enable automatic fixes for simple issues
    'auto_fix' => env('BFSG_AUTO_FIX', false),

    // Active checks to perform (all 16 analyzers)
    'checks' => [
        'images' => true,         // Alt text validation
        'forms' => true,          // Form label checking
        'headings' => true,       // Heading hierarchy
        'contrast' => true,       // Color contrast ratios (incl. CSS)
        'keyboard' => true,       // Keyboard navigation
        'aria' => true,           // ARIA attributes
        'links' => true,          // Link accessibility
        'language' => true,       // Language attributes
        'tables' => true,         // Table accessibility
        'media' => true,          // Video/audio captions
        'semantic' => true,       // Semantic HTML structure
        'page_title' => true,     // Page title (WCAG 2.4.2) (NEW in 2.0)
        'input_purpose' => true,  // Input purpose (WCAG 1.3.5) (NEW in 2.0)
        'focus' => true,          // Focus visible (WCAG 2.4.7) (NEW in 2.0)
        'error_handling' => true, // Error handling (WCAG 3.3.1/3.3.3) (NEW in 2.0)
        'status_messages' => true, // Status messages (WCAG 4.1.3) (NEW in 2.0)
    ],

    // Reporting configuration
    'reporting' => [
        'enabled' => env('BFSG_REPORTING', true),
        'email' => env('BFSG_REPORT_EMAIL', null),
        'save_to_database' => false,
    ],
];
```

Usage
-----

[](#usage)

### Command Line

[](#command-line)

The package provides two commands:

#### `bfsg:check` - Full-Featured Checker

[](#bfsgcheck---full-featured-checker)

For production use with authentication, reports, and database storage:

```
# Check your application's homepage
php artisan bfsg:check

# Check a specific URL
php artisan bfsg:check https://example.com

# Check with detailed output
php artisan bfsg:check https://example.com --detailed

# Generate HTML report with compliance score
php artisan bfsg:check https://example.com --format=html

# Generate JSON report
php artisan bfsg:check https://example.com --format=json

# Generate PDF report (requires barryvdh/laravel-dompdf)
php artisan bfsg:check https://example.com --format=pdf

# Save results to database for historical tracking
php artisan bfsg:check https://example.com --save
```

#### `bfsg:analyze` - Quick Analysis + SPA Support

[](#bfsganalyze---quick-analysis--spa-support)

For quick checks and Single Page Applications (React, Vue, Inertia):

```
# Quick server-side analysis
php artisan bfsg:analyze https://example.com

# Analyze SPAs with real browser rendering (Playwright)
php artisan bfsg:analyze https://example.com --browser

# Browser with visible window (debugging)
php artisan bfsg:analyze https://example.com --browser --headless=false

# Adjust timeout for slow-loading SPAs
php artisan bfsg:analyze https://example.com --browser --timeout=60000
```

#### `bfsg:history` - Report History

[](#bfsghistory---report-history)

View stored reports, track score trends, and manage historical data:

```
# View all stored reports
php artisan bfsg:history

# Filter by URL
php artisan bfsg:history --url=https://example.com

# Show score trends over time
php artisan bfsg:history --trends

# Cleanup reports older than 90 days
php artisan bfsg:history --cleanup --days=90
```

#### Authentication Support

[](#authentication-support)

Check protected pages that require authentication:

```
# With email/password authentication
php artisan bfsg:check https://example.com/dashboard --auth --email=user@example.com --password=secret

# Interactive authentication (prompts for credentials)
php artisan bfsg:check https://example.com/dashboard --auth

# With custom login URL
php artisan bfsg:check https://example.com/dashboard --auth --login-url=/admin/login

# With bearer token (for API authentication)
php artisan bfsg:check https://api.example.com/protected --bearer="your-api-token"

# With existing session cookie
php artisan bfsg:check https://example.com/dashboard --session="laravel_session=abc123..."

# With Laravel Sanctum
php artisan bfsg:check https://example.com/dashboard --auth --sanctum --email=user@example.com
```

MCP Server
----------

[](#mcp-server)

Laravel BFSG includes a built-in MCP (Model Context Protocol) server that allows AI assistants like Claude to directly run accessibility checks.

### Setup

[](#setup)

Start the MCP server:

```
php artisan bfsg:mcp-server
```

Add to your Claude Code MCP configuration (`.claude/settings.json` or project settings):

```
{
  "mcpServers": {
    "bfsg": {
      "command": "php",
      "args": ["artisan", "bfsg:mcp-server"],
      "cwd": "/path/to/your/laravel-project"
    }
  }
}
```

### Available Tools

[](#available-tools)

ToolDescription`analyze_html`Analyze raw HTML for accessibility violations`analyze_url`Fetch and analyze a URL`check_contrast`Check contrast ratio between two colors`list_analyzers`List all 16 analyzers with enabled status`get_history`Retrieve stored accessibility reports`get_report`Get a single report with all violations`generate_report`Analyze URL and generate formatted report (JSON/HTML/Markdown/PDF)### Programmatic Usage

[](#programmatic-usage)

```
use ItsJustVita\LaravelBfsg\Facades\Bfsg;

// Analyze HTML content
$html = '';
$violations = Bfsg::analyze($html);

// Check if content is accessible
if (!Bfsg::isAccessible($html)) {
    $violations = Bfsg::getViolations();
    // Handle violations
}
```

### Blade Components

[](#blade-components)

Use pre-built accessible components:

```
{{-- Accessible Image Component --}}

{{-- More components coming soon --}}
```

### Middleware (Optional)

[](#middleware-optional)

Add accessibility checking middleware to your routes:

```
// In app/Http/Kernel.php or bootstrap/app.php
protected $routeMiddleware = [
    'accessible' => \ItsJustVita\LaravelBfsg\Middleware\CheckAccessibility::class,
];

// In routes/web.php
Route::middleware(['accessible'])->group(function () {
    // Your routes
});
```

Available Analyzers (16 Total)
------------------------------

[](#available-analyzers-16-total)

### ImageAnalyzer

[](#imageanalyzer)

- Checks for missing alt attributes
- Validates decorative image markup
- Suggests appropriate alt text

### FormAnalyzer

[](#formanalyzer)

- Validates form labels
- Checks required field indicators
- Ensures proper ARIA labels

### HeadingAnalyzer

[](#headinganalyzer)

- Validates heading hierarchy (h1-h6)
- Checks for missing h1
- Ensures logical heading structure

### ContrastAnalyzer (enhanced in 2.0)

[](#contrastanalyzer-enhanced-in-20)

- Calculates color contrast ratios
- Validates against WCAG AA/AAA standards
- Checks text and background combinations
- **NEW**: Parses `` blocks via CssParser for CSS-based contrast checking
- **NEW**: Resolves cascade, specificity, and inheritance for accurate color detection

### AriaAnalyzer

[](#ariaanalyzer)

- Validates ARIA roles
- Checks ARIA properties
- Ensures proper ARIA relationships

### LinkAnalyzer

[](#linkanalyzer)

- Checks for descriptive link text
- Validates link context
- Identifies "click here" anti-patterns

### KeyboardNavigationAnalyzer

[](#keyboardnavigationanalyzer)

- Detects missing skip links
- Validates tab order and tabindex usage
- Checks for keyboard traps in modals
- Ensures click handlers are keyboard accessible
- Validates focus management
- Detects mouse-only event handlers

### LanguageAnalyzer

[](#languageanalyzer)

- Validates `lang` attribute on `` element
- Checks for valid ISO 639-1 language codes
- Detects language changes in content
- Validates `xml:lang` attributes (BFSG §3 requirement)

### TableAnalyzer

[](#tableanalyzer)

- Checks for `` elements
- Validates `` with proper `scope` attributes
- Detects tables without header cells
- Identifies layout tables vs data tables
- Validates complex table relationships

### MediaAnalyzer

[](#mediaanalyzer)

- Checks videos for captions/subtitles (``)
- Validates audio transcript references
- Detects autoplay issues
- Ensures controls are present
- Validates YouTube iframe caption parameters

### SemanticHTMLAnalyzer

[](#semantichtmlanalyzer)

- Validates landmark elements (``, ``, ``, ``)
- Detects "div-itis" (excessive div usage)
- Checks button vs link usage
- Validates section headings
- Ensures proper list structures

### PageTitleAnalyzer (NEW in 2.0)

[](#pagetitleanalyzer-new-in-20)

- Validates page `` element exists (WCAG 2.4.2)
- Checks for descriptive, non-generic titles
- Detects duplicate or missing titles

### InputPurposeAnalyzer (NEW in 2.0)

[](#inputpurposeanalyzer-new-in-20)

- Validates `autocomplete` attributes on input fields (WCAG 1.3.5)
- Checks for appropriate input purpose identification
- Ensures user data fields support autofill

### FocusAnalyzer (NEW in 2.0)

[](#focusanalyzer-new-in-20)

- Validates visible focus indicators (WCAG 2.4.7)
- Detects `outline: none` / `outline: 0` without replacement styles
- Checks for custom focus indicator implementations

### ErrorHandlingAnalyzer (NEW in 2.0)

[](#errorhandlinganalyzer-new-in-20)

- Validates form error identification (WCAG 3.3.1)
- Checks for error suggestions (WCAG 3.3.3)
- Ensures error messages are associated with form fields

### StatusMessageAnalyzer (NEW in 2.0)

[](#statusmessageanalyzer-new-in-20)

- Validates status messages use ARIA live regions (WCAG 4.1.3)
- Checks for `role="status"`, `role="alert"`, `aria-live` attributes
- Ensures dynamic content updates are announced to assistive technologies

Report Generation
-----------------

[](#report-generation)

Generate professional accessibility reports in multiple formats:

### HTML Reports

[](#html-reports)

Beautiful, printable reports with compliance scores and grades:

```
php artisan bfsg:check https://example.com --format=html
```

Reports include:

- **Compliance Score** (0-100%) with grade (A+ to F)
- **Detailed Statistics** (critical, errors, warnings, notices)
- **Issue Breakdown** by analyzer with severity badges
- **WCAG Rule References** for each violation
- **Suggestions** for fixing each issue

Reports are saved to `storage/app/bfsg-reports/`.

### PDF Reports

[](#pdf-reports)

Professional PDF reports for stakeholders and compliance documentation (requires `barryvdh/laravel-dompdf`):

```
php artisan bfsg:check https://example.com --format=pdf
```

### JSON Reports

[](#json-reports)

Machine-readable format for CI/CD integration:

```
php artisan bfsg:check https://example.com --format=json
```

### Programmatic Report Generation

[](#programmatic-report-generation)

```
use ItsJustVita\LaravelBfsg\Reports\ReportGenerator;

$violations = Bfsg::analyze($html);
$report = new ReportGenerator($url, $violations);

// Generate HTML report
$htmlReport = $report->setFormat('html')->generate();

// Or save to file
$filename = $report->setFormat('html')->saveToFile();

// Get statistics
$stats = $report->getStats();
// ['compliance_score' => 85, 'grade' => 'B+', 'total_issues' => 12, ...]
```

Database Persistence
--------------------

[](#database-persistence)

Track accessibility violations over time by saving reports to your database.

### Setup

[](#setup-1)

Publish and run the migrations:

```
php artisan vendor:publish --tag=bfsg-migrations
php artisan migrate
```

This creates `bfsg_reports` and `bfsg_violations` tables with corresponding `BfsgReport` and `BfsgViolation` Eloquent models.

### Saving Reports

[](#saving-reports)

```
# Save check results to database
php artisan bfsg:check https://example.com --save
```

### Viewing History

[](#viewing-history)

```
# View all stored reports
php artisan bfsg:history

# Filter by URL
php artisan bfsg:history --url=https://example.com

# Show score trends
php artisan bfsg:history --trends

# Cleanup old reports
php artisan bfsg:history --cleanup --days=90
```

Testing Single Page Applications (SPAs)
---------------------------------------

[](#testing-single-page-applications-spas)

For React, Vue, Inertia.js, and other SPAs, use browser rendering:

```
# Analyze with Playwright browser engine
php artisan bfsg:analyze https://spa-app.com --browser

# See full documentation
```

See [SPA-TESTING.md](SPA-TESTING.md) for complete guide including:

- Playwright setup and installation
- Browser configuration (Chromium, Firefox, WebKit)
- Timeout and wait selectors
- CI/CD integration
- Debugging with visible browser

Understanding Violations
------------------------

[](#understanding-violations)

Each violation includes:

```
[
    'type' => 'error',           // error, warning, or notice
    'rule' => 'WCAG 1.1.1',      // WCAG rule reference
    'element' => 'img',          // HTML element type
    'message' => 'Image without alt text found',
    'suggestion' => 'Add an alt attribute to describe the image',
    'auto_fixable' => true,      // Can be automatically fixed
]
```

Testing
-------

[](#testing)

Run the test suite (215 tests, 424 assertions):

```
composer test
```

Run specific tests:

```
php artisan test --filter=ImageAnalyzerTest
```

BFSG Compliance
---------------

[](#bfsg-compliance)

This package helps you comply with the German Barrierefreiheitsstärkungsgesetz (BFSG), which requires:

- **Level AA WCAG 2.1 Compliance** (minimum)
- **Perceivable** content (text alternatives, captions)
- **Operable** interfaces (keyboard accessible)
- **Understandable** information and UI
- **Robust** content for assistive technologies

### Key Dates

[](#key-dates)

- **June 28, 2025**: BFSG comes into full effect
- Applies to all digital products and services in Germany

Resources
---------

[](#resources)

- [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/)
- [BFSG Information (German)](https://www.bmas.de/DE/Service/Gesetze-und-Gesetzesvorhaben/barrierefreiheitsstaerkungsgesetz.html)
- [Laravel Documentation](https://laravel.com/docs)

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Issues
------

[](#issues)

If you discover any security-related issues, please email  instead of using the issue tracker.

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

Author
------

[](#author)

**Vitalis Feist-Wurm**

- Email:
- GitHub: [@itsjustvita](https://github.com/itsjustvita)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Acknowledgments
---------------

[](#acknowledgments)

- Thanks to the Laravel community
- Inspired by various accessibility tools and standards

---

*This package is actively maintained and regularly updated to comply with the latest WCAG guidelines and BFSG requirements.*

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~10 days

Total

12

Last Release

46d ago

Major Versions

1.5.1 → 2.0.02026-03-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21318499?v=4)[itsjustvita](/maintainers/itsjustvita)[@itsjustvita](https://github.com/itsjustvita)

---

Top Contributors

[![itsjustvita](https://avatars.githubusercontent.com/u/21318499?v=4)](https://github.com/itsjustvita "itsjustvita (14 commits)")

---

Tags

laravelaccessibilitywcaga11ybfsg

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/itsjustvita-laravel-bfsg/health.svg)

```
[![Health](https://phpackages.com/badges/itsjustvita-laravel-bfsg/health.svg)](https://phpackages.com/packages/itsjustvita-laravel-bfsg)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k9.6k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90128.1k](/packages/emargareten-inertia-modal)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3614.9k](/packages/linkxtr-laravel-qrcode)[wearepixel/laravel-cart

A cart implementation for Laravel

1355.6k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
