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

apnet/coding-standard

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. Installation Run:

    composer require --dev apnet/coding-standard
    

    Add the package to your project’s phpcs.xml or phpcs.xml.dist:

    <config name="standard" value="Apnet"/>
    
  2. Basic Usage Run PHPCS (PHP Code Sniffer) with the new standard:

    vendor/bin/phpcs --standard=Apnet src/
    

    Verify the ruleset loads without errors.

  3. First Use Case Use it to enforce team-wide consistency in a new project or refactor an existing one. Start with a single file or directory to test:

    vendor/bin/phpcs --standard=Apnet --report=full src/App/Services/
    

Implementation Patterns

Daily Workflows

  1. Pre-Commit Hooks Integrate with tools like php-cs-fixer or husky to auto-check code before commits:

    composer require --dev php-cs-fixer
    

    Add a script to package.json:

    "scripts": {
      "test:cs": "phpcs --standard=Apnet src/ && php-cs-fixer fix src/"
    }
    
  2. CI/CD Pipeline Add a step in GitHub Actions/GitLab CI to enforce standards:

    - name: Run PHPCS
      run: vendor/bin/phpcs --standard=Apnet --warning-severity=0 src/
    
  3. Custom Rule Overrides Extend or override rules in phpcs.xml:

    <rule ref="Apnet">
        <exclude name="Generic.Files.LineEndings"/>
        <arg name="lineEndings" value="unix"/>
    </rule>
    
  4. Team Onboarding Document the coding standard in CONTRIBUTING.md and include a quick-start guide:

    ## Coding Standards
    Run `composer test:cs` to check your code against our standard.
    

Gotchas and Tips

Common Pitfalls

  1. Rule Conflicts If rules clash with other standards (e.g., PSR-12), explicitly exclude or override them in phpcs.xml:

    <rule ref="Apnet">
        <exclude name="Apnet.Spaces.BlankLineBeforeNamespace"/>
    </rule>
    
  2. Performance Avoid running PHPCS on large codebases without caching. Use --cache:

    vendor/bin/phpcs --standard=Apnet --cache=/tmp/phpcs-cache src/
    
  3. Undocumented Rules The package lacks a README or changelog. Inspect the source ruleset (if available) or use:

    vendor/bin/phpcs --standard=Apnet --list-rules
    
  4. PHP Version Compatibility Test with your project’s PHP version (e.g., 8.0+). Some rules may fail silently.

Pro Tips

  • Pair with php-cs-fixer Auto-fix issues where possible:
    vendor/bin/php-cs-fixer fix --rules=@Apnet src/
    
  • Custom Sniffs Extend the standard by creating a custom sniff in app/Ruleset/Apnet/.
  • Visual Studio Code Integration Add to .vscode/settings.json:
    "php.validate.executablePath": "vendor/bin/phpcs",
    "php.validate.run": "onType",
    "php.validate.args": ["--standard=Apnet"]
    
  • Ignore Files Exclude files/directories in phpcs.xml:
    <file>vendor/</file>
    <file>tests/</file>
    
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.
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle
dmstr/api-platform-utils-bundle
dmstr/api-configuration-bundle
chrisdev/ux-components
baks-dev/finances
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle