jidaikobo/a11yc

Static accessibility checker core for A11YC

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 16

Watchers: 8

Forks: 0

Open Issues: 0

pkg:composer/jidaikobo/a11yc

6.0.1 2026-03-02 12:41 UTC

This package is auto-updated.

Last update: 2026-03-02 12:44:09 UTC


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 7.4 or later
  • Composer

Installation

composer require jidaikobo/a11yc

If you are working on this repository directly:

composer install

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