jeroen-g/autowire
jeroen-g/autowire is a Laravel package that automates dependency injection by resolving and wiring class dependencies, reducing manual container boilerplate. It keeps controllers and services clean and makes Laravel code easier to maintain.
composer.json constraints and run composer why-not vendor/package 3.0 if the upgrade is blocked.composer require vendor/package:^3.0 (or composer update vendor/package --with-dependencies). Because this is a major bump, review the diff in your composer.lock and run the full test suite immediately after upgrading.config/ file (if published). The headline 3.0 feature for day-to-day use is the WithCachedAutowire trait, so start by applying it to your base TestCase.tests/TestCase.php and run a representative slice of your test suite. This is the lowest-risk way to validate that cached autowiring works with your service provider graph before rolling it out across the whole suite.// tests/TestCase.php
use Vendor\Package\Testing\WithCachedAutowire;
abstract class TestCase extends BaseTestCase
{
use WithCachedAutowire;
}
boost/ or documented install command rather than guessing.WithCachedAutowire on the base TestCase so every feature/unit test benefits. For suites with wildly different container needs, apply it selectively on test classes or a shared CachedContainerTestCase base instead of globally.RefreshDatabase / DatabaseTransactions carefully. The trait caches container resolution; if a test mutates bindings (e.g. $this->app->bind(...) or instance() swaps), reset or avoid the cache for that class. A common pattern is a small base class for tests that need fresh bindings and the cached base for everything else.setUp() before the first resolution that exercises the cached path. If you use $this->mock() / $this->partialMock(), verify the cached autowire result still reflects the mock—if not, resolve those dependencies through the container after binding or disable caching for that test.^3.0, then run the cached-autowire test suite as an integration smoke test for the container changes Laravel 13 introduces.composer update will work.bind/singleton/instance mutations in setUp() and either reset the container or exclude that test from the cached path.TestCase and re-run the failing test. If it passes without the trait, the issue is cache lifetime, not your binding logic.config() between cases and rely on container re-resolution (e.g. drivers, mailers, filesystems) are the most common source of flakiness. Set config before the app boots, or use a non-cached base class for those tests.TestCase thin. Wrap the trait behind a project-specific base class so you can swap caching behavior, add resets, or disable it for specific test groups without touching every test.How can I help you explore Laravel packages today?