Weave 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

Robo Phpcs Laravel Package

sweetchuck/robo-phpcs

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require --dev sweetchuck/robo-phpcs
    

    Ensure robo/robo is also installed (required dependency).

  2. Basic RoboFile Integration: Add the task to your RoboFile.php:

    use Sweetchuck\RoboPhpcs\RoboPhpcs;
    
    $tasks = new RoboPhpcs($this);
    
  3. First Use Case: Run PHPCS on a directory (e.g., src/):

    robo phpcs:run --dir=src/
    

    Defaults to app/ if no directory is specified.


Implementation Patterns

Common Workflows

  1. Pre-Commit Hook:

    $this->taskExec('git')->hook('pre-commit')
        ->exec('robo phpcs:run --dir=src/ --standard=PSR12 --report=json');
    
  2. CI Integration: Fail the build on errors:

    $this->taskPhpcsRun()
        ->dir('src/')
        ->standard('PSR12')
        ->failOnError()
        ->run();
    
  3. Custom Standards: Load a custom .phpcs.xml file:

    $this->taskPhpcsRun()
        ->config('tests/phpcs.xml')
        ->run();
    

Task Composition

Chain PHPCS with other tasks (e.g., tests):

$tasks = $this->taskPhpcsRun()->dir('src/');
$tasks->then($this->taskExec('phpunit'));

Reporting

Generate reports for CI tools:

robo phpcs:run --dir=src/ --report=json --report-file=phpcs-report.json

Gotchas and Tips

Pitfalls

  1. Robo Version: Requires Robo 1.0.0-RC1+ (check composer.json for conflicts).

  2. PHPCS Configuration: If no --standard is set, defaults to PSR2 (not PSR12). Explicitly specify:

    robo phpcs:run --standard=PSR12
    
  3. Path Resolution: Relative paths (e.g., --dir=src/) are resolved from the project root. Use absolute paths if needed:

    robo phpcs:run --dir=/full/path/to/src
    

Debugging

  • Verbose Output: Enable PHPCS debug mode:
    robo phpcs:run --debug
    
  • Dry Run: Test without modifying files:
    robo phpcs:run --dry-run
    

Extension Points

  1. Custom Rules: Extend PHPCS rules via phpcs.xml and reference them in tasks:

    $this->taskPhpcsRun()->config('custom-rules.xml')->run();
    
  2. Parallel Execution: Use Robo’s parallel tasks for large codebases:

    $this->taskPhpcsRun()->parallel()->run();
    
  3. Event Listeners: Hook into PHPCS events (e.g., file processing) via Robo’s event system:

    $this->taskPhpcsRun()->on('task.phpcs.run', function ($task) {
        // Custom logic
    });
    
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.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels