Guidance for AI/coding agents working in this repository.
- Type: PHP library
- Goal: Generate secure, memorable passphrases (Bitwarden-inspired)
- Primary namespace:
NicoBleiler\Passphrase\ - PHP version: 8.2+
- Optional integration: Laravel 11+
src/— Core library codePassphraseGenerator.php— main generation logicWordList.php— word list loading/validationPassphraseServiceProvider.php— Laravel service wiringFacades/Passphrase.php— Laravel facadeExceptions/— package-specific exception types
config/passphrase.php— publishable Laravel config defaultsresources/wordlists/eff_large_wordlist.php— bundled default word list (compiled PHP array)tests/— PHPUnit tests (unit + Laravel integration via Testbench)
- Install dependencies:
composer install
- Run tests:
composer test- or
vendor/bin/phpunit
Agents should run tests after meaningful changes, especially for behavior updates.
- Preserve PSR-4 structure and the
NicoBleiler\Passphrase\namespace. - Keep public APIs stable unless explicitly asked to change them.
- Prefer small, focused changes over broad refactors.
- Avoid introducing framework-specific coupling in core classes unless change is Laravel integration related.
- Keep error handling explicit with package exception types where appropriate.
- Maintain compatibility with PHP 8.2.
PassphraseGeneratorusesRandom\Randomizer(default:Random\Engine\Secure) for all randomness. Do not userandom_int()directly.- The
Randomizeris injected via constructor for testability. Do not add separate RNG-callable methods.
- Add/adjust tests in
tests/for any behavioral change. - Deterministic tests inject a seeded
Random\Randomizer(usingXoshiro256StarStarengine) via the constructor. Do not use custom callable RNG patterns. - Validate edge cases already reflected by the suite:
- word-count bounds
- separator behavior (including multibyte)
- capitalization behavior (including Unicode)
- optional number insertion behavior
- EFF/custom word list array behavior
- Default behavior relies on the bundled EFF long list.
- Custom word lists are provided as PHP arrays (config
word_listorWordList::fromArray()). - Optional exclusion of words is provided via config
excluded_wordsand$wordlist->excludeWords(). - Do not add logging/output that could leak generated passphrases.
- Keep service provider bindings/facade alias behavior intact.
- The service provider wires
config/passphrase.phpvalues intoPassphraseGenerator::setDefaults(). Passphrase::generate()without arguments uses config defaults; explicit params override them.PassphraseGenerator::generate(targetEntropyBits: ...)is a per-call entropy target and takes precedence overnumWords.targetEntropyBitsis not part ofsetDefaults()and is not read from Laravel config (notarget_entropy_bitskey inconfig/passphrase.php).- If config keys change, update tests and docs consistently.
When changing behavior or public options:
- Update
README.mdandAGENTS.mdexamples/options. - Ensure configuration docs stay aligned with
config/passphrase.php.
- Use the Conventional Commits format from https://www.conventionalcommits.org/.
- Prefer clear, scoped commit types (for example:
feat:,fix:,docs:,chore:). - Use
!or aBREAKING CHANGE:footer when introducing breaking changes.
- Understand current behavior before editing.
- Implement the minimum safe change.
- Run tests.
- Summarize what changed and why.