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

Coding Standard Laravel Package

webimpress/coding-standard

Opinionated PHP_CodeSniffer rules from Webimpress for consistent PHP style. Extends common standards, adds project conventions, and ships with ready-to-use configs for enforcing formatting and best practices across your codebase.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install: Run composer require --dev webimpress/coding-standard in any PHP project.
  2. Basic Setup: Create a phpcs.xml (or phpcs.dist.xml) file in your project root with:
    <?xml version="1.0"?>
    <ruleset name="CustomStandard">
        <rule ref="Webimpress"/>
    </ruleset>
    
  3. First Run: Execute vendor/bin/phpcs to scan your codebase. You’ll see violations matching the standard’s rules (e.g., PSR-12 deviations, internal naming conventions, strict type usage, etc.).
  4. Fix Automatically: Use vendor/bin/phpcbf to auto-fix many formatting issues (e.g., indentation, spacing, use statement order).

Start by scanning a small module or legacy file to gauge impact—this standard is stricter than PSR-12 in areas like method visibility, property typing, and docblock syntax.

Implementation Patterns

  • Centralized Config: In monorepos, define phpcs.xml in the root and include it via <configValue name="installed_paths" value="vendor/webimpress/coding-standard"/> to reference the standard without duplicating config.
  • CI Integration: Add to GitHub Actions, GitLab CI, or local pre-commit hooks:
    - name: Run PHPCS
      run: vendor/bin/phpcs --standard=Webimpress
    
  • IDE Integration: Configure PHP Intelephense or PhpStorm to use PHPCS via phpcs.xml, or install VS Code extensions that support custom standards.
  • Per-Project Overrides: Extend the standard for edge cases:
    <rule ref="Webimpress">
        <exclude name="Webimpress.Arrays.ArrayDeclaration.SpaceAfterComma"/>
        <property name="tabIndent" value="true"/>
    </rule>
    
  • Teams: Share the standard across repositories by requiring webimpress/coding-standard as a dev dependency—no custom ruleset needed unless exceptions apply.

Gotchas and Tips

  • Strict declare(strict_types=1); Enforcement: The standard requires strict types in all files. Legacy files may fail until updated—use phpcbf or target exclusions carefully.
  • PHP Version Compatibility: The latest version targets PHP 8.0+ and may flag issues on older codebases (e.g., typed properties, union types). Verify your PHP version matches the target environment.
  • webimpress/phpcs-compat Dependency: Ensure squizlabs/php_codesniffer is ≥3.7—older versions may not support newer sniffs.
  • False Positives on Traits: Some traits with self type hints may trigger SelfUsage.Found errors. Use <exclude-pattern> in phpcs.xml for non-applicable files, or suppress selectively with // @codingStandardsIgnore.
  • Custom Extensions: Extend rules by creating your own sniffs in app/Sniffs/ and registering them via <rule ref="YourOwnStandard">, but prefer patching upstream if rules conflict meaningfully.
  • Debugging: Use phpcs -s to see which sniff caused a violation, or --report=checkstyle for CI-friendly output. Log verbose errors with --runtime-set testVersion 8.2.
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
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
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests