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

Testbench Core Laravel Package

orchestra/testbench-core

Orchestra Testbench Core is the foundation for testing Laravel packages. It boots a lightweight Laravel app inside your package so you can run artisan commands, migrations, routing, and more, with compatibility across Laravel 6–12.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Accelerate Laravel Package Development: Enables rapid iteration and validation of Laravel packages by providing a lightweight, isolated testing environment. Reduces friction in testing package-specific logic (e.g., service providers, migrations, commands) without requiring a full Laravel installation.
  • Standardize Testing Practices: Aligns testing workflows across teams by offering a consistent framework for unit, feature, and integration tests. Supports PHPUnit and PestPHP, reducing tooling fragmentation.
  • Build vs. Buy Decision: Justifies not building a custom testing framework for Laravel packages, leveraging a battle-tested, community-driven solution with 272+ stars and Laravel 13.x compatibility.
  • Roadmap for Test-Driven Development (TDD): Facilitates TDD for Laravel packages by simplifying setup of test databases, migrations, and service providers. Key for teams adopting package-first development (e.g., SaaS platforms, modular Laravel apps).
  • Use Cases:
    • Package Publishers: Validate package functionality before release (e.g., spatie/laravel-permission).
    • Enterprise Laravel Apps: Test custom packages/modules in isolation (e.g., payment gateways, auth systems).
    • Education/Boilerplates: Teach Laravel testing best practices via pre-configured test skeletons.

When to Consider This Package

  • Adopt When:

    • Developing Laravel packages (not full applications) that require testing service providers, migrations, or Artisan commands.
    • Teams need fast, isolated test environments without spinning up a full Laravel app (e.g., CI/CD pipelines).
    • Using PHPUnit/PestPHP and want seamless Laravel integration (e.g., mocking Facades, testing middleware).
    • Requiring BrowserKit/Dusk-like testing for package UI components (via testbench-browser-kit/testbench-dusk).
    • Laravel version is 10.x–13.x (package supports all major releases).
  • Look Elsewhere If:

    • Testing a full Laravel application (not a package). Use Laravel’s built-in testing helpers or PestPHP directly.
    • Need end-to-end (E2E) testing with real browsers (consider Laravel Dusk or Playwright).
    • Using non-Laravel PHP frameworks (Symfony, Lumen). Testbench is Laravel-specific.
    • Requiring performance benchmarking (use Laravel’s phpunit.xml optimizations or custom scripts).
    • Already invested in a custom testing framework with deep integration into your workflow.

How to Pitch It (Stakeholders)

For Executives:

"Testbench Core lets our engineering team validate Laravel packages 10x faster by eliminating the need to manually set up test environments. For example, when building our [Package Name], developers can now test migrations, commands, and service providers in isolated containers—reducing bugs in production by 30% (based on similar teams). It’s a low-risk, high-reward investment: open-source (MIT license), actively maintained, and used by top Laravel package authors like Spatie. This aligns with our goal to ship modular, reliable components for [Product Name]."

ROI:

  • Time Saved: Cuts package testing time from hours to minutes per feature.
  • Quality: Catches integration issues early (e.g., package conflicts, migration errors).
  • Scalability: Supports parallel testing for CI/CD pipelines.

For Engineering Leaders:

*"Testbench Core is the de facto standard for testing Laravel packages. Here’s why we should adopt it:

  1. Unified Testing: Standardizes how we test packages across teams (PHPUnit/PestPHP support).
  2. Laravel Alignment: Works seamlessly with Laravel’s ecosystem (Facades, Artisan, migrations).
  3. Extensions: Need to test UI components? Add testbench-browser-kit or testbench-dusk. Want to preview packages locally? Use workbench.
  4. Future-Proof: Actively maintained (releases for Laravel 13.x), with PHP 8.5+ support.

Migration Path:

  • Start with orchestra/testbench for core testing.
  • Add testbench-browser-kit if testing Blade views.
  • Replace custom test setups with Testbench’s traits (e.g., WithMigrations, WithFactories).

Alternatives: Building our own framework would duplicate effort—Testbench is battle-tested by 272+ GitHub stars and the Laravel community."*


For Developers:

*"Testbench makes testing Laravel packages painless. Here’s how it changes your workflow:

  • No More Manual Setup: Spin up a Laravel environment in tests with one line:
    $app = require __DIR__.'/../../vendor/laravel/framework/src/Illuminate/Foundation/bootstrap/app.php';
    
  • Test Anything:
    • Migrations: @withMigrations(['CreateUsersTable']).
    • Commands: $this->artisan('package:command').
    • Routes: $response = $this->get('/api/endpoint').
  • Isolation: Each test runs in a clean state (no shared DB/cache pollution).
  • PestPHP Support: Works out-of-the-box with Pest’s syntax.

Example:

use Orchestra\Testbench\TestCase;

class UserPackageTest extends TestCase {
    protected function getPackageProviders($app) {
        return ['App\Providers\UserPackageServiceProvider'];
    }

    public function test_user_creation() {
        $this->artisan('migrate')
             ->assertExitCode(0);
        $this->post('/users', ['name' => 'John'])
             ->assertCreated();
    }
}

Pro Tip: Pair with testbench-browser-kit to test Blade forms without JavaScript:

$this->visit('/dashboard')
     ->type('John', 'input[name="name"]')
     ->press('Submit')
     ->see('Welcome, John');
```"*
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata