azjezz/psl
PSL is a modern, well-typed standard library for PHP 8.4+, inspired by HHVM’s HSL. It offers safer, predictable APIs for async, collections, networking, I/O, crypto, terminal UI, and robust data validation—replacing brittle built-ins with consistent alternatives.
The detect-packages command scans PHP source directories for PSL namespace usage and reports which php-standard-library/* standalone packages are needed. This helps migrate from the monorepo to individual packages.
This tool is only available when using the monorepo (php-standard-library/php-standard-library).
vendor/bin/psl detect-packages <path>... [--dev <path>...] [--composer]
| Option | Description |
|---|---|
--src |
Mark following paths as require dependencies (default) |
--dev |
Mark following paths as require-dev dependencies |
--composer |
Output a JSON snippet for composer.json |
Scan a single source directory:
vendor/bin/psl detect-packages src/
Detected PSL packages:
require:
php-standard-library/dict
php-standard-library/foundation
php-standard-library/str
php-standard-library/vec
Scan source and test directories separately. Packages found in both are placed in require only:
vendor/bin/psl detect-packages src/ --dev tests/
Detected PSL packages:
require:
php-standard-library/dict
php-standard-library/foundation
php-standard-library/str
php-standard-library/vec
require-dev:
php-standard-library/filesystem
php-standard-library/os
Use --composer to get output you can paste directly into your composer.json:
vendor/bin/psl detect-packages src/ --dev tests/ --composer
{
"require": {
"php-standard-library/dict": "^6.1",
"php-standard-library/str": "^6.1",
"php-standard-library/vec": "^6.1"
},
"require-dev": {
"php-standard-library/filesystem": "^6.1",
"php-standard-library/os": "^6.1"
}
}
You can pass multiple directories. Bare paths default to require:
vendor/bin/psl detect-packages src/ lib/ --dev tests/
The tool scans all .php files in the given directories and matches Psl\<Namespace> references using regex. Each namespace is mapped to its corresponding standalone package. The foundation package is always included when any PSL usage is detected, since all PSL packages depend on it.
Transitive dependencies are not resolved — only direct usage in your code is reported. Composer handles transitive dependencies automatically when you install the standalone packages.
How can I help you explore Laravel packages today?