doctrine/instantiator
Lightweight PHP library to instantiate objects without calling their constructors. Useful for hydrators, serializers, proxies, and testing/mocking. Part of the Doctrine ecosystem; creates instances via reflection while avoiding side effects and required constructor args.
Architecture fit: The package fits as a niche utility for specific testing and ORM scenarios within Laravel. While Laravel's Eloquent ORM doesn't natively require it, it becomes valuable when working with Doctrine ORM integrations (e.g., laravel-doctrine), or when testing classes with complex constructor dependencies (e.g., private constructors, final classes). It complements Laravel's testing tools but isn't core to standard Eloquent workflows.
Integration feasibility: High. Composer-based installation is trivial, and Laravel's dependency management handles it seamlessly. Minimal code changes needed—only required in specific test or serialization contexts.
Technical risk: Low. Widely adopted (11k+ stars) with stable maintenance. However, misuse in production code (e.g., bypassing constructors for non-testing purposes) could introduce hidden state issues.
Key questions:
Mockery, PHPUnit mocks) already cover these use cases without extra dependencies?newInstanceWithoutConstructor()) that replicate this functionality?Stack fit: Primarily a dev dependency for testing and Doctrine ORM-related workflows. Fits cleanly in Laravel's ecosystem as a lightweight, isolated tool for edge-case object instantiation—ideal for testing legacy code or third-party libraries with restrictive constructors. Not relevant for standard Eloquent model hydration.
Migration path:
composer.json as dev dependency: composer require --dev doctrine/instantiator.private __construct()).How can I help you explore Laravel packages today?