malikad778/laravel-blade-ally 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

malikad778/laravel-blade-ally

Composer 安装命令:

composer require malikad778/laravel-blade-ally

包简介

Static Accessibility Analyzer for Laravel Blade & Livewire Templates

README 文档

README

Static Accessibility Analyzer for Laravel Blade & Livewire Templates
Catch WCAG 2.2 AA violations in your PHP source code before a single request is served.

Latest Version on Packagist Tests PHP Version Laravel Version License: MIT EAA Compliant

Why laravel-blade-ally Exists

The European Accessibility Act (EAA) came into force in June 2025. WCAG AA compliance is now a legal requirement for public-facing web applications across the EU.

Existing tools like axe-core, Lighthouse, and WAVE run in the browser at runtime—after your code has been deployed. They catch nothing in CI. They cannot easily analyze dynamic Blade conditionals, Livewire component trees, or slot-rendered layouts, and they require a running server.

laravel-blade-ally is the missing layer: a static analysis engine that parses your Blade templates and Livewire components as source code, detects WCAG violations before compilation, and integrates into your CI/CD pipeline—acting just like PHPStan but for your frontend accessibility.

🚀 Installation

You can install the package via composer (typically as a development dependency):

composer require malikad778/laravel-blade-ally --dev

You can publish the configuration file using:

php artisan ally:init

This will publish the blade-ally.php config file to your config/ directory.

🛠️ Usage

Run the static analyzer across your entire resources/views and app/Livewire directories:

php artisan ally:analyze

Options

  • Specify paths: php artisan ally:analyze resources/views/components app/Livewire
  • Change output format: php artisan ally:analyze --format=json (Available formats: terminal, json, html, checkstyle, github, sarif, junit)
  • Filter by severity: php artisan ally:analyze --severity=error

Understand a Rule

If you want to know why a specific rule failed or how to fix it:

php artisan ally:explain img-missing-alt

Working with Baselines

Just like PHPStan, you can create a baseline to ignore existing legacy violations and only enforce rules on new code:

php artisan ally:baseline

Subsequent runs of ally:analyze will automatically ignore the violations recorded in the baseline file.

✨ Feature Overview

Core Engine

  • Full Blade Parser: Understands @if, @foreach, @include, @extends, @yield, <x-components>, and <x-slot> layouts.
  • Smart Livewire Analyzer: Understands wire:click, wire:loading, wire:navigate, and correlates Livewire PHP class logic with the component's Blade view.
  • Alpine.js Aware: Respects x-on:click, x-show, and dynamically bound Alpine attributes.
  • CI/CD Ready: Returns hard exit codes on failures. Native support for GitHub Annotations and SARIF (for GitHub Code Scanning security tabs).

Complete WCAG Coverage (73 Rules Across 13 Categories)

The engine currently validates exactly 73 distinct criteria, including:

  • Images & Media (SC 1.1.1, 1.2.x): Enforces meaningful alt text, prevents redundant filenames in alts, enforces <svg> titles, catches div backgrounds used as generic images, and checks for <video> captions.
  • Forms (SC 1.3.1, 3.3.2): Validates implicit and explicit <label> connections. Ensures required fields have correct aria-required tags, and input validation is properly linked via aria-describedby or role="alert".
  • Buttons & Links (SC 2.4.4, 4.1.2): Catches empty links, generic "click here" text, Javascript href voids, and <div role="button"> missing keyboard tabindexes.
  • Tables & Structure (SC 1.3.1): Enforces correct <th> scopes, catches skipped heading levels (e.g., h2 to h4), missing <main> landmarks, and duplicate <h1> tags.
  • Modals & Dialogs (SC 4.1.2): Enforces role="dialog", trapped focus management, and @keydown.escape handlers.
  • ARIA Verification (SC 4.1.2): Prevents impossible ARIA roles, validates parent/child ARIA associations (e.g. role="rowheader" must be inside a row container), and prevents aria-hidden on focusable elements.
  • Livewire Specific:
    • livewire-poll-no-pause: Enforces wire:poll.visible for performance and screen-reader sanity.
    • wire-loading-aria-live: Ensures visual wire:loading states are announced to screen readers.
    • livewire-dispatch-focus: Tracks missing focus management when Livewire dispatches DOM-altering events.

⚙️ Configuration

Your config/blade-ally.php allows fine-grained control over the analysis:

return [
    'paths' => [
        resource_path('views'),
        app_path('Livewire'),
    ],
    
    // Ignore specific files or directories
    'exclude_paths' => [
        resource_path('views/vendor'),
    ],

    // Toggle individual rules
    'rules' => [
        'img-alt-filename' => false, // Disable specific rule
        'heading-multiple-h1' => true,
    ],
];

🔄 Continuous Integration

laravel-blade-ally is designed for automated checks.

GitHub Actions Example

name: Accessibility Analysis
on: [push, pull_request]

jobs:
  blade-ally:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.2'
      - run: composer install --prefer-dist --no-progress
      - name: Run Blade Ally
        run: php artisan ally:analyze --format=github

Using --format=github will place inline annotations directly on your Pull Request files!

🧪 Testing

We use Pest/PHPUnit to ensure parser integrity and rule accuracy:

composer test

(Tests cover HTML implicit semantics, Blade tokenization, Livewire bindings, and AST traversal).

📄 License

The MIT License (MIT). Please see License File for more information.

malikad778/laravel-blade-ally 适用场景与选型建议

malikad778/laravel-blade-ally 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「accessibility」 「blade」 「static-analysis」 「wcag」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 malikad778/laravel-blade-ally 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 malikad778/laravel-blade-ally 我们能提供哪些服务?
定制开发 / 二次开发

基于 malikad778/laravel-blade-ally 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 38
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-13