Perform real accessibility audits on web pages using Playwright PHP and axe-core,
checking for WCAG, ARIA, color contrast, and best-practice compliance.
This package relies on Playwright PHP - to install it, follow the instructions in Playwright PHP’s installation guide.
composer require --dev playwright-php/accessibilityuse Playwright\Accessibility\AxeBuilder; $builder = new AxeBuilder($page); $results = $builder->analyze(); if ($results->hasViolations()) { foreach ($results->violations as $violation) { echo "{$violation->id}: {$violation->help}\n"; } }use Playwright\Accessibility\AssertsAccessibility; class MyTest extends TestCase { use AssertsAccessibility; public function testPageIsAccessible(): void { $page->goto('https://example.com'); $this->assertIsAccessible($page); } }// Scope to specific regions $builder->within('#main-content')->analyze(); // Filter by WCAG level $builder->withTags([WcagTag::WCAG_2_1_AA])->analyze(); // Disable specific rules $builder->withoutRules([RuleId::COLOR_CONTRAST])->analyze(); // Exclude elements $builder->exclude('.advertisement')->analyze();This package is released by the Playwright PHP project under the MIT License. See the LICENSE file for details.
