Skip to content

Commit 9ce8bc5

Browse files
committed
playwright-php/accessibility
0 parents  commit 9ce8bc5

40 files changed

+3135
-0
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.git* export-ignore
2+
/docs/ export-ignore
3+
/tests/ export-ignore
4+
/.php-cs-fixer.dist.php export-ignore
5+
/phpstan.dist.neon export-ignore
6+
/phpunit.dist.xml export-ignore

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [smnandre]

.github/worflows/CI.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
pull_request:
7+
branches: [ "*" ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
19+
cs:
20+
uses: playwright-php/.github/workflows/CS.yml@main
21+
# with:
22+
# php-version: '8.4'
23+
# composer-validate: true
24+
# php-cs-fixer-args: '--diff --dry-run'
25+
26+
sa:
27+
uses: playwright-php/.github/workflows/SA.yml@main
28+
# with:
29+
# php-version: '8.4'
30+
# phpstan-args: 'analyse --no-progress --memory-limit=-1'

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.phpunit.cache/
2+
/test-failures/
3+
/vendor/
4+
/.php-cs-fixer.cache
5+
/composer.lock
6+
/coverage.xml
7+
/phpstan.neon
8+
/phpunit.xml

.php-cs-fixer.dist.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
$license = <<<LICENSE
4+
This file is part of the community-maintained Playwright PHP project.
5+
It is not affiliated with or endorsed by Microsoft.
6+
7+
(c) 2025-Present - Playwright PHP - https://github.com/playwright-php
8+
9+
For the full copyright and license information, please view the LICENSE
10+
file that was distributed with this source code.
11+
LICENSE;
12+
13+
$finder = (new PhpCsFixer\Finder())
14+
->in(__DIR__);
15+
16+
return (new PhpCsFixer\Config())
17+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
18+
->setFinder($finder)
19+
->setRiskyAllowed(true)
20+
->setRules([
21+
'@Symfony' => true,
22+
'declare_strict_types' => true,
23+
'header_comment' => ['header' => $license],
24+
'phpdoc_to_comment' => false,
25+
])
26+
;

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
MIT License
2+
3+
Copyright (c) 2025-present Simon André & Playwright PHP
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
---
24+
25+
See NOTICE file for additional details.

NOTICE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
2+
3+
This project depends on Playwright, an open-source project by Microsoft,
4+
available at https://github.com/microsoft/playwright and licensed under
5+
the Apache License 2.0 (https://github.com/microsoft/playwright/blob/main/LICENSE).
6+
"Playwright" is a trademark of Microsoft. This project is independent and not
7+
affiliated with or endorsed by Microsoft.

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<div align="center">
2+
<img src="https://github.com/playwright-php/.github/raw/main/profile/playwright-php.png" alt="Playwright PHP" />
3+
4+
&nbsp; ![PHP Version](https://img.shields.io/badge/PHP-8.2-05971B?labelColor=09161E&color=1D8D23&logoColor=FFFFFF)
5+
&nbsp; ![CI](https://img.shields.io/github/actions/workflow/status/playwright-php/accessibility/ci.yml?branch=main&label=Tests&color=1D8D23&labelColor=09161E&logoColor=FFFFFF)
6+
&nbsp; ![Release](https://img.shields.io/github/v/release/playwright-php/accessibility?label=Stable&labelColor=09161E&color=1D8D23&logoColor=FFFFFF)
7+
&nbsp; ![License](https://img.shields.io/github/license/playwright-php/accessibility?label=License&labelColor=09161E&color=1D8D23&logoColor=FFFFFF)
8+
9+
</div>
10+
11+
# Playwright PHP - Accessibility
12+
13+
> [!IMPORTANT]
14+
> This package is **experimental**. Its API may still change before the upcoming `1.0` release.
15+
>
16+
> Curious or interested? Try it out, [share your feedback](https://github.com/playwright-php/accessibility/issues), or ideas!
17+
18+
Perform real **accessibility audits** on web pages using [Playwright PHP](https://github.com/playwright-php/playwright) and [axe-core](https://github.com/dequelabs/axe-core),
19+
checking for **WCAG**, **ARIA**, color contrast, and best-practice compliance.
20+
21+
## Installation
22+
23+
This package relies on **Playwright PHP** - to install it, follow the instructions in [Playwright PHP’s installation guide](https://github.com/playwright-php/playwright#installation).
24+
25+
```bash
26+
composer require --dev playwright-php/accessibility
27+
````
28+
29+
## Usage
30+
31+
### Basic Analysis
32+
33+
```php
34+
use Playwright\Accessibility\AxeBuilder;
35+
36+
$builder = new AxeBuilder($page);
37+
$results = $builder->analyze();
38+
39+
if ($results->hasViolations()) {
40+
foreach ($results->violations as $violation) {
41+
echo "{$violation->id}: {$violation->help}\n";
42+
}
43+
}
44+
```
45+
46+
### PHPUnit Integration
47+
48+
```php
49+
use Playwright\Accessibility\AssertsAccessibility;
50+
51+
class MyTest extends TestCase
52+
{
53+
use AssertsAccessibility;
54+
55+
public function testPageIsAccessible(): void
56+
{
57+
$page->goto('https://example.com');
58+
$this->assertIsAccessible($page);
59+
}
60+
}
61+
```
62+
63+
### Advanced Configuration
64+
65+
```php
66+
// Scope to specific regions
67+
$builder->within('#main-content')->analyze();
68+
69+
// Filter by WCAG level
70+
$builder->withTags([WcagTag::WCAG_2_1_AA])->analyze();
71+
72+
// Disable specific rules
73+
$builder->withoutRules([RuleId::COLOR_CONTRAST])->analyze();
74+
75+
// Exclude elements
76+
$builder->exclude('.advertisement')->analyze();
77+
```
78+
79+
## License
80+
81+
This package is released by the [Playwright PHP](https://playwright-php.dev) project
82+
under the **MIT License**. See the [LICENSE](LICENSE) file for details.

composer.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "playwright-php/accessibility",
3+
"description": "Accessibility testing for Playwright PHP using axe-core. Check web pages for WCAG compliance.",
4+
"license": "MIT",
5+
"type": "library",
6+
"keywords": [
7+
"playwright",
8+
"accessibility",
9+
"a11y",
10+
"a11y-php",
11+
"axe",
12+
"axe-core",
13+
"wcag",
14+
"contrast-checker",
15+
"testing",
16+
"browser-testing"
17+
],
18+
"authors": [
19+
{
20+
"name": "Simon André",
21+
"email": "smn.andre@gmail.com",
22+
"homepage": "https://github.com/smnandre"
23+
},
24+
{
25+
"name": "Playwright PHP Contributors",
26+
"homepage": "https://github.com/playwright-php"
27+
}
28+
],
29+
"homepage": "https://playwright-php.dev",
30+
"require": {
31+
"php": "^8.2",
32+
"playwright-php/playwright": "dev-main"
33+
},
34+
"require-dev": {
35+
"friendsofphp/php-cs-fixer": "^3.40",
36+
"phpstan/phpstan": "^2.1",
37+
"phpunit/phpunit": "^12.3"
38+
},
39+
"minimum-stability": "stable",
40+
"prefer-stable": true,
41+
"autoload": {
42+
"psr-4": {
43+
"Playwright\\Accessibility\\": "src/"
44+
}
45+
},
46+
"autoload-dev": {
47+
"psr-4": {
48+
"Playwright\\Accessibility\\Tests\\": "tests/"
49+
}
50+
},
51+
"config": {
52+
"allow-plugins": {
53+
"phpstan/extension-installer": true
54+
},
55+
"sort-packages": true
56+
},
57+
"extra": {
58+
"branch-alias": {
59+
"dev-main": "0.x-dev"
60+
},
61+
"thanks": {
62+
"name": "playwright-php/playwright",
63+
"url": "https://github.com/playwright-php/playwright"
64+
}
65+
}
66+
}

phpstan.dist.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: 10
3+
paths:
4+
- src/
5+
- tests/
6+
treatPhpDocTypesAsCertain: false

0 commit comments

Comments
 (0)