Guides

PHPRegex plugs into the tools you already run. Every integration installs one package, registers itself, and starts reporting — the commands below are the target form; until the 2.0.0 tag, the monorepo install covers them all, see the Quick Start.

Static analysis

PHPStan

Reports the regex patterns your target PHP refuses — and, on demand, lint, ReDoS and optimization findings inside static analysis.

composer require --dev php-regex/regex-phpstan

Psalm

Types $matches from the pattern — the shape of the captures, not array<array-key, string> — and reports the patterns your target PHP refuses.

composer require --dev php-regex/regex-psalm

Rector

Rewrites a preg_* call into the string function that does the same, only when the automata prove the two answer alike on every subject.

composer require --dev php-regex/regex-rector

Frameworks

Laravel

The Regex service and facade, with the php artisan regex:lint, regex:routes, regex:explain, regex:compare and regex:transpile commands.

composer require --dev php-regex/regex-laravel

Symfony

The php_regex.regex service, with the bin/console regex:lint, regex:routes, regex:security, regex:analyze, regex:compare and regex:transpile commands.

composer require --dev php-regex/regex-symfony

Editors

LSP

Diagnostics, hovers, completions and code actions for the patterns of PHP files, in any editor that speaks the Language Server Protocol.

composer require --dev php-regex/regex-language-server

The CLI

CLI

Sixteen subcommands to parse, explain, validate, lint, hunt ReDoS, transpile and diagram — also a self-contained PHAR.

composer require --dev php-regex/regex-cli

Deep dives

ReDoS guide

What PHPRegex proves about a pattern — the verdicts, the guarantees, confirmed mode, and how to fix a vulnerable pattern. The redos() API ships in the toolkit.

composer require --dev php-regex/regex-toolkit

Regex in PHP

How PCRE behaves inside preg_* — delimiters, flags, the functions and their return values — no install required, just PHP.

Edit on GitHub