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

Devtools Laravel Package

moox/devtools

moox/devtools is a Laravel devtools package that streamlines local development with helpful utilities and tooling for debugging, scaffolding, and productivity. Built to integrate cleanly into Laravel apps and speed up everyday developer workflows.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation: Add the package to your Laravel project via Composer:

    composer require --dev moox/devtools
    

    This installs a curated set of dev tools including Pest, Larastan (PHPStan), Pint, and Livewire/Pest plugins.

  2. First Use Case: Run your first Pest test to verify integration:

    ./vendor/bin/pest
    

    If successful, you’ll see output like:

    PASS  Tests/Unit/ExampleTest.php
    ✓ it works (0.1s)
    
  3. Where to Look First:

    • Pest Configuration: Check tests/Pest.php for plugin and preset settings.
    • Larastan Rules: Inspect .larastan.neon in the project root for static analysis rules.
    • Pint Rules: Review .pint.php for code formatting preferences.
    • Blade Capture: Use {{ @capture }} in Blade templates for testing (documented in README.md if available).

Implementation Patterns

Daily Workflows

  1. Testing with Pest:

    • Unit Tests: Place in tests/Unit/ with Pest’s fluent syntax:
      test('user can be created', function () {
          $user = User::factory()->create();
          expect($user->email)->toBeValid();
      });
      
    • Feature Tests: Use in tests/Feature/ with Laravel helpers:
      test('GET /dashboard', function () {
          $response = $this->get('/dashboard');
          $response->assertStatus(200);
      });
      
    • Livewire Tests: Leverage the included plugin:
      test('livewire component renders', function () {
          Livewire::test(ProfileComponent::class)
              ->assertSee('Profile');
      });
      
  2. Static Analysis:

    • Run Larastan in CI/CD pipelines:
      ./vendor/bin/larastan analyse --level=5 app
      
    • Integrate with Git hooks for pre-commit checks:
      ./vendor/bin/larastan analyse --memory-limit=1G --error-format=json
      
  3. Code Formatting:

    • Auto-format codebase:
      ./vendor/bin/pint --test  # Dry run
      ./vendor/bin/pint        # Apply fixes
      
    • Add to composer.json scripts:
      "scripts": {
          "lint": "pint",
          "test": "pest"
      }
      
  4. Blade Testing:

    • Capture Blade output for assertions:
      {{ @capture('header') }}
          <h1>{{ $title }}</h1>
      {{ @endcapture }}
      
      test('blade header', function () {
          BladeCapture::capture('header', ['title' => 'Test']);
          expect(BladeCapture::get('header'))->toContain('Test');
      });
      

Integration Tips

  • Laravel Projects:

    • Use pest-plugin-laravel for seamless Laravel integration (e.g., actingAs, assertDatabaseHas).
    • Configure Testbench in phpunit.xml for legacy tests:
      <testsuites>
          <testsuite name="Unit">
              <directory>./tests/Unit</directory>
          </testsuite>
      </testsuites>
      
  • Livewire:

    • Test components with the included plugin:
      test('livewire emits events', function () {
          Livewire::test(Counter::class)
              ->emit('increment')
              ->assertEmitted('increment');
      });
      
  • CI/CD:

    • Example GitHub Actions workflow:
      name: Laravel Tests
      on: [push]
      jobs:
        test:
          runs-on: ubuntu-latest
          steps:
            - uses: actions/checkout@v4
            - uses: actions/setup-php@v3
              with:
                php-version: '8.2'
            - run: composer install --dev
            - run: ./vendor/bin/pest
            - run: ./vendor/bin/larastan analyse --level=5 app
            - run: ./vendor/bin/pint --test
      
  • Customization:

    • Override default configurations by placing custom files in the project root (e.g., .pint.php, .larastan.neon).

Gotchas and Tips

Pitfalls

  1. Version Lock-in:

    • The meta-package pins specific versions of tools (e.g., Pest v4, Pint v1). Upgrading individual tools may require manual version overrides in composer.json.
    • Fix: Use replace in composer.json to force a version:
      "replace": {
          "pestphp/pest": "6.0"
      }
      
  2. Larastan Strictness:

    • Default rules may flag false positives (e.g., Laravel magic methods). Customize .larastan.neon:
      ignores = [
          'app/Helpers/*',
          'app/Models/Concerns/*'
      ]
      
  3. Pest Plugin Conflicts:

    • Plugins like pest-plugin-livewire may conflict with custom Pest configurations. Ensure tests/Pest.php is minimal:
      uses(Tests\TestCase::class)->in('Feature');
      uses(PestPluginLivewire::class)->in('Feature');
      
  4. Blade Capture Limitations:

    • The @capture directive requires Laravel’s Blade compiler. Gotcha: Fails in non-Laravel contexts (e.g., CLI scripts).
    • Fix: Use BladeCapture::capture() in tests instead:
      BladeCapture::capture('template', ['data' => $data]);
      
  5. Testbench vs. Pest:

    • Mixing TestCase from Testbench and Pest can cause conflicts. Stick to one:
      // Pest
      use Tests\TestCase;
      class MyTest extends TestCase { ... }
      
      // Testbench (legacy)
      use Orchestra\Testbench\TestCase;
      class LegacyTest extends TestCase { ... }
      
  6. Pint Presets:

    • The default Pint preset may not match your team’s style. Customize .pint.php:
      return Pint::laravel()->withRules([
          Pint\Rule\NoTrailingWhitespace::class,
      ]);
      

Debugging

  • Pest:

    • Enable verbose output:
      ./vendor/bin/pest --debug
      
    • Check for plugin loading errors in bootstrap/Pest.php.
  • Larastan:

    • Generate a baseline for gradual adoption:
      ./vendor/bin/larastan baseline app
      
    • Use --error-format=json for CI-friendly parsing.
  • Composer Conflicts:

    • Resolve dependency conflicts with:
      composer why-not moox/devtools
      composer why pestphp/pest
      

Extension Points

  1. Custom Pest Plugins:

    • Publish plugins to composer.json and register in tests/Pest.php:
      uses(MyCustomPlugin::class)->in('Unit');
      
  2. Larastan Rules:

    • Extend rules in .larastan.neon:
      extends = [larastan/laravel.neon]
      rules = [
          \Moox\CustomRule::class
      ]
      
  3. Pint Rules:

    • Add custom rules to .pint.php:
      return Pint::laravel()->withRules([
          Pint\Rule\NoTrailingWhitespace::class,
          Pint\Rule\LineEnding::class,
      ]);
      
  4. Testbench Extensions:

    • Override providers in tests/CreatesApplication.php:
      protected function getPackageProviders($app) {
          return [
              \Moox\YourPackage\ServiceProvider::class,
          ];
      }
      
  5. Git Hooks:

    • Add pre-commit checks in .git/hooks/pre-commit:
      #!/bin/sh
      ./vendor/bin/pint --test || exit 1
      ./vendor/bin/larastan analyse --level=5 --error-format=json | jq -e '. >/dev/null' || exit 1
      
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.
ilhamsyabani/laravel-volt-starter
thethunderturner/filament-latex
ghostcompiler/laravel-querybuilder
webrek/laravel-telescope-mongodb
anousss007/blatui
zatona-eg/zatona-eg-api
cocosmos/filament-sticky-save-bar
patrickbussmann/oauth2-apple
3brs/enterprise-security-bundle
anousss007/vigilance
supportpal/eloquent-model
ardenexal/fhir-models
laravel-at/laravel-image-sanitize
romalytar/yammi-audit-log-laravel
ardenexal/fhir-validation
arshaviras/weather-widget
laravel-chronicle/core
sunchayn/nimbus
daikazu/eloquent-salesforce-objects
unseen-codes/chat