-
Notifications
You must be signed in to change notification settings - Fork 1
Installation
| Component | Minimum | Notes |
|---|---|---|
| PHP | 7.4 | Tested on 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 in CI. |
ext-ctype |
always | Used for the digit-only fast path in every context escaper. |
ext-mbstring |
always | Required for the encoding-conversion fallback when ext-iconv is not available. Composer enforces it. |
ext-iconv |
optional but preferred | If present, used in place of mbstring for iconv()-based conversion. Composer lists it under suggest. |
composer require initphp/escaperThe package is autoloaded under the InitPHP\Escaper\ namespace; nothing else needs to be wired.
<?php
require __DIR__ . '/vendor/autoload.php';
use InitPHP\Escaper\Esc;
echo Esc::esc('<script>alert(1)</script>');
// <script>alert(1)</script>If the script prints <script>alert(1)</script>, the autoload is wired correctly.
For local testing, static analysis and coding-standard checks, the project's own composer.json declares:
"require-dev": {
"phpunit/phpunit": "^9.6 || ^10.5 || ^11.5",
"phpstan/phpstan": "^1.12 || ^2.1",
"friendsofphp/php-cs-fixer": "^3.65"
}You only need these if you're contributing to the package itself. The composer.json exposes them via four scripts:
| Script | What it does |
|---|---|
composer test |
Run the PHPUnit test suite. |
composer stan |
Run PHPStan at the configured (max) level. |
composer cs-check |
Report PHP-CS-Fixer violations without modifying any file. |
composer cs-fix |
Apply PHP-CS-Fixer fixes in place. |
composer ci |
Run cs-check + stan + test back-to-back. |
The package's GitHub Actions workflow runs on every push and pull request and executes:
-
composer validate --strict(one job). - PHP-CS-Fixer (one job).
- PHPStan at
level: max(one job). - PHPUnit across PHP 7.4 → 8.4, with an extra
--prefer-lowestvariant on the lowest and highest PHP in the matrix. - A coverage job that uploads to Codecov.
The workflow file lives at .github/workflows/ci.yml.
Read Quick Start for a 5-minute tour, or jump straight to the context page that matches your task — HTML body, HTML attribute, JavaScript, CSS, URL.
Getting Started
Entry Points
Output Contexts
Reference
Production
Migration & Help