mrclay/props-dic
A lightweight PHP DI container that exposes services as typed properties and factory methods ($c->foo, $c->new_foo()), letting you add @property/@method PHPDoc for IDE autocomplete and static analysis. Supports lazy resolution, caching, and factories.
$container->get('service')).'user_repository') with typed properties ($container->userRepository), reducing runtime errors and improving maintainability.AuthServices, PaymentServices) with IDE support for cross-module navigation.Props\Pimple.$container instances) and lacks type safety.new_user() vs. user()).$container['key']) and don’t want to refactor to property access.*"Props is a low-risk, high-reward upgrade to our dependency injection system. It transforms our container from a 'black box' into a self-documenting tool, cutting debugging time by 30%+ while keeping our existing DI logic intact. For minimal effort, we’ll gain:
*"Props solves two critical pain points:
$container->get(). Now $container->userRepository is autocompleted with type hints.$container->new_connection(). Need the cached one? $container->connection. This is cleaner than Pimple’s offsetGet/offsetSet and works seamlessly with static analyzers.
Migration Path:AppContainer extends Props\Container).@property-read and @method PHPDoc blocks.$container['service'] with $container->service in new code.
Trade-offs: Slightly more boilerplate for setup, but zero runtime cost and better tooling long-term. Let’s pilot it in [Module X] first to validate the benefits."**"Props is a lightweight, PSR-11-compliant DI container that excels in IDE integration and static analysis. Here’s how it fits into our stack:
Psr\Container\ContainerInterface, so it can coexist with Laravel’s container (though not replace it fully).Props\Pimple allows gradual migration from Pimple without rewriting DI logic.bind() → setFactory()).App\Services\AuthContainer) where IDE support is critical.*"Props improves dependency injection clarity, which directly benefits testing:
$container->userRepository) make it obvious what a class depends on, simplifying mocking in tests.new_* pattern (e.g., $container->new_user()) ensures test isolation by avoiding cached singletons.
Potential Impact:UndefinedIndexException or ContainerException errors in tests.How can I help you explore Laravel packages today?