jidaikobo/a11yc 问题修复 & 功能扩展

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

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

jidaikobo/a11yc

Composer 安装命令:

composer require jidaikobo/a11yc

包简介

Static accessibility checker core for A11YC

README 文档

README

License: MIT

a11yc is the core accessibility checking library extracted from A11YC.

This package is a PHP library, not the old standalone web application. It provides HTML and URL analysis APIs that can be embedded in other applications such as the standalone UI layer or the jwp-a11y WordPress plugin.

Requirements

  • PHP 8.3 or later
  • Composer

Installation

composer require jidaikobo/a11yc

If you are working on this repository directly:

composer install

Compiled Resources

Runtime resource loading now expects precompiled PHP arrays in resources/compiled/.

The distributed package should include:

  • resources/compiled/ja.php
  • resources/compiled/en.php

When you change resource source files under resources/, rebuild the compiled files before committing or packaging:

composer compile-resources

This command regenerates the compiled PHP arrays from the YAML source files.

At runtime, a11yc uses the compiled files first. If they are missing, the library raises an error unless YAML fallback is explicitly enabled for development.

Development-Only YAML Fallback

For local development only, you can allow direct YAML loading with a Git-ignored config.development.php file in the package root:

<?php

return array(
    'allow_yaml_fallback' => true,
);

This file is not intended for distribution. In normal packaged environments, keep compiled resources available and do not rely on YAML fallback.

What This Package Does

  • Fetch and analyze a page by URL
  • Analyze already-available HTML
  • Return normalized issue lists and summary counts
  • Extract image metadata used by the analyzer
  • Load WCAG-related resources from bundled YAML files

Basic Usage

Analyze a URL

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Jidaikobo\A11yc\Analyzer;

$analyzer = new Analyzer();

$result = $analyzer->analyzeUrl('https://example.com/', array(
    'do_link_check' => false,
    'do_css_check' => false,
    'include_images' => true,
));

Analyze HTML

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Jidaikobo\A11yc\Analyzer;

$html = '<!doctype html><html lang="ja"><head><title>Example</title></head><body><img src="/logo.png" alt=""></body></html>';

$analyzer = new Analyzer();

$result = $analyzer->analyzeHtml($html, array(
    'url' => 'https://example.com/',
    'is_partial' => false,
    'do_link_check' => false,
    'do_css_check' => false,
    'include_images' => true,
));

Result Format

Analyzer::analyzeUrl() and Analyzer::analyzeHtml() return an array with these top-level keys:

  • meta
  • summary
  • issues
  • images

meta

  • url: analyzed URL
  • requested_url: original requested URL (only for analyzeUrl())
  • exists: whether fetching succeeded (only for analyzeUrl())
  • user_agent: effective user agent string
  • version: A11YC_VERSION if defined
  • check_count: number of executed checks
  • analyzed_at: ISO 8601 timestamp

summary

  • error_count
  • notice_count
  • counts_by_level

counts_by_level contains:

  • a
  • aa
  • aaa

issues

Each issue is normalized into a flat array:

  • id
  • type (error or notice)
  • message
  • level
  • criterion_keys
  • place_id
  • snippet

images

When include_images is enabled, image data includes:

  • element
  • src
  • alt
  • href
  • is_important
  • aria

Available Options

Both Analyzer::analyzeUrl() and Analyzer::analyzeHtml() accept an options array.

  • url: base URL for analysis (analyzeHtml() only; default about:blank)
  • user_agent: user agent used for fetching HTML/CSS
  • checks: array of check class names to run; omitted means all available checks
  • is_partial: skip full-document assumptions for partial HTML analysis
  • do_link_check: enable slower link validation checks
  • do_css_check: enable CSS fetching and CSS-related checks
  • include_images: include extracted image data in the result

Lower-Level API

If you need the raw validation result set before normalization:

<?php

use Jidaikobo\A11yc\Validate;

$resultSet = Validate::html(
    'https://example.com/',
    $html,
    array(),
    'using',
    true,
    array(
        'is_partial' => false,
        'do_link_check' => false,
        'do_css_check' => false,
    )
);

The normalized API via Analyzer is recommended for new integrations.

License

MIT

jidaikobo/a11yc 适用场景与选型建议

jidaikobo/a11yc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 16, 最近一次更新时间为 2026 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 jidaikobo/a11yc 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-02