jakub-onderka/php-parallel-lint
Abandoned PHP tool for fast parallel linting (syntax checking) of PHP files with colored output and formats like Checkstyle/JSON. Install via Composer and run on directories with options for excludes, jobs, stdin, and git blame. Suggested alternative: php-parallel-lint/PHP-Parallel-Lint
Installation:
composer require --dev jakub-onderka/php-parallel-lint
composer require --dev jakub-onderka/php-console-highlighter # For colored output
Basic Usage: Run in your project root to check all PHP files:
vendor/bin/parallel-lint .
php,php3,php4,php5,phtml,phpt files.-j 10).First Use Case: Integrate into your CI pipeline (e.g., GitHub Actions, GitLab CI) to catch syntax errors early:
# Example GitHub Actions step
- name: Run PHP Parallel Lint
run: vendor/bin/parallel-lint --exclude vendor --exclude tests .
Local Development:
inotifywait or nodemon) to auto-check files on save:
# Linux (requires inotify-tools)
inotifywait -m -e modify -e create -e delete src/ | while read -r event; do vendor/bin/parallel-lint src/; done
--json for programmatic integration:
vendor/bin/parallel-lint --json . > lint-results.json
CI/CD Integration:
--ignore-fails to treat warnings as non-fatal:
vendor/bin/parallel-lint --ignore-fails --exclude vendor .
vendor/bin/parallel-lint --checkstyle . > lint-results.xml
Symfony-Specific:
app/ and vendor/ directories:
vendor/bin/parallel-lint --exclude app --exclude vendor .
php-cs-fixer for linting + formatting:
vendor/bin/parallel-lint . && vendor/bin/php-cs-fixer fix --dry-run
Git Hooks:
pre-commit hook to block syntax errors:
# .git/hooks/pre-commit
#!/bin/sh
vendor/bin/parallel-lint --exclude vendor .
-j based on your machine’s CPU cores (e.g., -j 8 for 8 cores).--php /usr/bin/php8.1).--blame to pinpoint who introduced syntax errors:
vendor/bin/parallel-lint --blame --git /usr/bin/git .
find src/ -name "*.php" | vendor/bin/parallel-lint --stdin
Abandoned Package:
composer.json to avoid breaking changes:
"jakub-onderka/php-parallel-lint": "dev-master"
HHVM Support:
False Positives:
eval(), create_function()) may trigger false errors.--ignore-fails.Memory Usage:
-j) can spike memory. Monitor with htop and adjust -j if needed.Windows Paths:
/) or escape backslashes (\\) in --exclude paths.-vvv for debug logs (not officially documented but works in some versions).$xml = simplexml_load_file('lint-results.xml');
foreach ($xml->file as $file) {
echo "Errors in {$file['name']}: " . $file->error->count() . "\n";
}
jq:
vendor/bin/parallel-lint --json . | jq '.[] | select(.errors | length > 0)'
Custom PHP.ini:
Override settings via environment variables (e.g., PHP_INI_SCAN_DIR for custom php.ini paths).
Pre/Post-Processing:
Chain with other tools (e.g., parallel-lint | grep "ERROR" for quick checks).
GitHub Actions: Cache results to avoid re-linting unchanged files:
- name: Cache Parallel Lint
uses: actions/cache@v2
with:
path: ~/.parallel-lint-cache
key: ${{ runner.os }}-lint-${{ hashFiles('**/*.php') }}
Docker: Use in CI containers to ensure consistency:
RUN composer require jakub-onderka/php-parallel-lint --dev
CMD ["vendor/bin/parallel-lint", "--exclude vendor", "."]
-s if your project uses <? syntax.--asp for legacy <?php ... ?>-like tags.--no-progress for CI environments where it adds noise.How can I help you explore Laravel packages today?