orchestra/testbench
Orchestra Testbench is the de-facto Laravel testing helper for package development. It boots a lightweight Laravel app for your package’s tests, making it easy to run PHPUnit/Pest suites with proper service providers, config, and environment setup.
flushState() for JsonResource, Validator).Adopt Testbench if:
Auth, Cache, Queue) without booting a full app.WithFixtures trait).Str::macro(), Model eager-loading).Look elsewhere if:
For Executives: *"Testbench is the industry-standard tool for testing Laravel packages, used by over 2,000+ open-source projects. By adopting it, we’ll:
For Engineering Teams: *"Testbench gives us:
PaymentGateway package in isolation).Auth, Cache, or Queue with fakes in seconds.Str::macro(), Model caches) between tests.
Example: Testing our Notification package? Testbench lets us mock the Mailer and Queue services, verify notifications are dispatched, and reset state—all without a real app.
Tradeoff: A slight learning curve for Laravel’s service container, but the payoff is massive for package maintainability."*For Developers: *"If you’re working on a Laravel package, Testbench is your secret weapon:
php artisan serve: Test your package’s logic without spinning up a full Laravel app.Auth::user()? Done. Test a Command without hitting the filesystem? Done.WithFixtures.flushState() to avoid ‘test pollution’ from global Laravel state (e.g., Str::macro() or Validator rules).
Start here: Official Docs + the create-testbench skeleton generator."*How can I help you explore Laravel packages today?