peckphp/peck
Peck is a fast CLI spell-checker for your codebase—filenames, class/method/property names, docs, and more. Powered by GNU Aspell, it helps catch wording and spelling mistakes and fits neatly into workflows like Pint or Pest. Requires PHP 8.2+ and Aspell.
Installation:
composer require --dev peckphp/peck
peck.json in project root):
./vendor/bin/peck --init
First Run:
./vendor/bin/peck
laravel preset (auto-applied via --init):
{
"preset": "laravel"
}
Quick Use Case:
getUserData → getUserDatas). Peck will flag it during development or CI runs.Pre-commit Hook:
Add to composer.json to run Peck before commits:
"scripts": {
"lint:peck": "peck --quiet"
}
Run via:
composer lint:peck
IDE Integration:
Use --text to validate strings on-the-fly (e.g., commit messages or docblocks):
./vendor/bin/peck --text "This is a test string with a typo"
- name: Spell Check
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
sudo apt-get install -y aspell aspell-en
fi
composer require --dev peckphp/peck
./vendor/bin/peck --report=checkstyle > spelling-report.xml
spelling-report.xml as an artifact for review.Project-Specific Ignores:
Extend peck.json to ignore Laravel-specific terms or paths:
{
"preset": "laravel",
"ignore": {
"words": ["eloquent", "blade", "facade"],
"paths": ["storage/*", "tests/Feature/*"]
}
}
Language Support:
Switch to a non-US English dictionary (e.g., en_GB) for UK-based projects:
{
"language": "en_GB"
}
peck.json to version control to enforce consistent spelling across the team.--ignore-all sparingly (e.g., during initial setup):
./vendor/bin/peck --ignore-all
Then manually curate peck.json afterward.False Positives:
userId) or acronyms (e.g., API, HTML).ignored_words or use inline comments:
// @peck-skip
public function getUserId() { ... }
Aspell Dependency:
Performance:
peck.json or use --path:
./vendor/bin/peck --path=app/Http
Config Overrides:
--ignore-all) temporarily override peck.json.--config to test changes without modifying the shared file:
./vendor/bin/peck --config custom-peck.json
Verbose Output:
Use --verbose to debug file exclusions or Aspell interactions:
./vendor/bin/peck --verbose
Suggestion Rejection:
If Peck suggests incorrect replacements (e.g., configArray → configurationArray), add the original term to ignored_words.
Custom Presets:
laravel preset by copying its rules to a new config file and modifying ignored_words.Plugin Development:
// Extend Peck\Peck\Processors\AbstractProcessor
class BladeProcessor extends AbstractProcessor { ... }
Reporting Formats:
Report classes (e.g., for Slack notifications or Jira tickets).Blade Files:
Peck skips Blade files by default. To include them, add to peck.json:
{
"include": ["*.blade.php"]
}
Database Migrations: Ignore migration files if they contain raw SQL with non-standard terms:
{
"ignore": {
"paths": ["database/migrations/*"]
}
}
Artisan Commands:
Use --text to validate command descriptions in app/Console/Kernel.php:
./vendor/bin/peck --text "This command does something useful"
How can I help you explore Laravel packages today?