Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Codesniffer Laravel Package

squizlabs/php_codesniffer

PHP_CodeSniffer (PHPCS) provides phpcs to detect coding standard violations and phpcbf to automatically fix them. Tokenizes PHP files against defined standards to keep code clean and consistent, suitable for teams and CI.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing PHP_CodeSniffer via Composer in your project’s require-dev section ("squizlabs/php_codesniffer": "^4.0"), then run ./vendor/bin/phpcs src/ to validate against PSR-12 by default. If violations appear, fix them manually or run ./vendor/bin/phpcbf src/ for automatic corrections. For team use, create a phpcs.xml ruleset file in your project root to define standards, exclude paths, and configure sniffs—this becomes your single source of truth and works seamlessly in CI pipelines.

Implementation Patterns

  • Standardized CI checks: Integrate phpcs in GitHub Actions/GitLab CI with --error-severity=1 --warning-severity=1 to fail jobs only on critical violations. Use parallel scanning (-p flag) for speed.
  • Custom standards: Extend built-in standards (e.g., PSR12) in ruleset.xml by adding/removing individual sniffs, overriding properties (e.g., indent width), or defining custom sniff classes.
  • IDE integration: Configure PHPStorm or VS Code to use phpcs for live linting—use phpcs:ignore and phpcs:enable annotations in docblocks to suppress per-file/per-line warnings where justified.
  • Pre-commit hooks: Add phpcbf to a pre-commit hook (e.g., via Husky or Git hooks) to auto-fix issues before staging, ensuring commits always conform to style guides.

Gotchas and Tips

  • Backward compatibility: Upgrading to v4+ requires reviewing the 4.0 Upgrade Guide; changes include how fully qualified keywords are tokenized and stricter annotation parsing.
  • Ruleset quirks: ruleset.xml properties like severity or exclude accept comma-separated values but fail silently if whitespace is included—use <property name="tabIndent" value="true"/> instead of <property name="tabIndent" value= " true " />.
  • Debugging false positives: Run phpcs -s --sniffs=Generic.WhiteSpace.ScopeIndent src/MyFile.php to see exact sniff names and token details. Use --runtime-set testVersion 8.3 to simulate PHP version behavior during parsing.
  • Extensibility: Write custom sniffs by extending AbstractSniff and override process()—place them in YourStandard/Sniffs/ and reference them in ruleset.xml. Test them via phpcs -p to see progress during rule development.
  • Performance: Scan only changed files in CI using git diff --name-only main | grep .php$ | xargs phpcs, or enable parallel_errors for faster reports.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4