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

All Tasks Laravel Package

phpcq/all-tasks

phpcq/all-tasks bundles the full set of PHPCQ tasks into one convenient package, so you can install and run multiple code quality tools with a single dependency. Ideal for setting up consistent linting, testing, and analysis in your PHP projects.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the package via Composer:

    composer require phpcq/all-tasks --dev
    

    Ensure it’s listed under require-dev in composer.json.

  2. First Use Case Run the predefined PHP Code Quality (PHP-CQ) tasks via Artisan:

    php artisan php-cq:run
    

    This executes all default tasks (e.g., static analysis, coding standards, tests).

  3. Configuration Check config/php-cq.php (auto-generated if missing) for task overrides or custom rules. Example:

    'tasks' => [
        'phpstan' => [
            'level' => 'level:5',
        ],
        'psalm' => [
            'enabled' => true,
        ],
    ],
    

Implementation Patterns

Workflow Integration

  1. CI/CD Pipeline Trigger tasks in GitHub Actions/GitLab CI:

    # Example GitHub Actions
    - name: Run PHP-CQ
      run: php artisan php-cq:run --ansi
    

    Use --ansi for colored output in CI logs.

  2. Pre-Commit Hooks Integrate with laravel-pint or husky:

    composer require laravel-pint --dev
    php artisan php-cq:run --tasks=pint
    
  3. Custom Task Groups Define reusable task sets in php-cq.php:

    'groups' => [
        'core' => ['phpstan', 'psalm', 'phpunit'],
        'pre-release' => ['phpstan', 'phpunit', 'pest'],
    ],
    

    Run via:

    php artisan php-cq:run --group=core
    

Artisan Command Usage

Command Purpose
php artisan php-cq:run Execute all tasks.
php artisan php-cq:task Run a specific task (e.g., phpstan).
php artisan php-cq:config Dump current config to php-cq.php.

Task-Specific Patterns

  • PHPStan/Psalm: Leverage Laravel’s service container to bind custom rules:
    // app/Providers/AppServiceProvider.php
    public function register()
    {
        $this->app->bind(\PHPStan\Rules\Rule::class, function () {
            return new CustomRule();
        });
    }
    
  • PHPUnit: Extend Laravel’s testing config (phpunit.xml) to include:
    <env name="APP_ENV" value="testing"/>
    <env name="DB_CONNECTION" value="sqlite"/>
    

Gotchas and Tips

Common Pitfalls

  1. Task Dependencies

    • Ensure phpstan/extension-installer and phpunit/phpunit are installed if using those tasks.
    • Fix: Run composer require --dev phpcq/all-tasks again or manually add missing packages.
  2. Configuration Overrides

    • Custom php-cq.php may conflict with package defaults. Use php artisan php-cq:config to reset.
    • Tip: Merge configs explicitly:
      return [
          'tasks' => array_merge(
              require __DIR__.'/php-cq.php',
              ['phpstan' => ['level' => 'level:7']]
          ),
      ];
      
  3. Performance

    • Parallelize tasks with --parallel (if supported):
      php artisan php-cq:run --parallel --tasks=phpstan,psalm
      
    • Warning: Not all tasks support parallel execution (e.g., PHPUnit).
  4. Debugging

    • Enable verbose output:
      php artisan php-cq:run --verbose
      
    • Check task logs in storage/logs/php-cq.log.

Extension Points

  1. Custom Tasks Extend the package by creating a service provider:

    // app/Providers/PHPcqServiceProvider.php
    public function boot()
    {
        \PHPcq\AllTasks::extend(function ($manager) {
            $manager->addTask(new CustomTask());
        });
    }
    
  2. Hooks Listen to task events (e.g., phpcq.task.started):

    // app/Listeners/LogTaskEvents.php
    public function handle()
    {
        Log::info('Task started: '.$event->task);
    }
    
  3. Environment-Specific Configs Use Laravel’s environment configs:

    // config/php-cq.php
    'tasks' => env('PHP_CQ_TASKS', ['phpstan', 'phpunit']),
    

Pro Tips

  • Cache Task Results: Add --cache to skip unchanged files:
    php artisan php-cq:run --cache
    
  • GitHub Actions: Cache Composer dependencies and task results:
    - uses: actions/cache@v3
      with:
        path: ~/.cache/php-cq
        key: ${{ runner.os }}-php-cq-${{ hashFiles('**/composer.lock') }}
    
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor