Weave 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
Laminas Servicemanager

Laminas Servicemanager Laravel Package

laminas/laminas-servicemanager

Laminas ServiceManager is a PSR-11 compatible dependency injection container for PHP. It supports factory-based service creation, aliases, abstract factories, delegators, and lazy loading, making it a flexible foundation for managing object dependencies.

View on GitHub
Deep Wiki
Context7

Factory-Driven Dependency Injection Container

Frequently asked questions about Laminas Servicemanager
Is laminas/laminas-servicemanager a Laravel package?
No. It is the Laminas factory-driven dependency injection container and a PSR-11 implementation, and it is framework-agnostic. Laravel already ships Illuminate\Container with service providers, facades, and contextual binding. Adding ServiceManager means running a second, parallel container, so use it only when a specific dependency requires Laminas semantics.
How do I install laminas/laminas-servicemanager in a Laravel application?
Install it with Composer using composer require laminas/laminas-servicemanager. Register a single ServiceManager instance as a singleton in a Laravel service provider, then configure only the factories and aliases the third-party library needs. Expose it behind a narrow interface and avoid injecting it into controllers or jobs. Application code should keep resolving through Laravel's container.
Can Laminas ServiceManager and Laravel's container coexist in one app?
Technically yes, because both satisfy PSR-11 and can be bridged. In practice this creates a dual-container anti-pattern: scoped and singleton lifetimes become ambiguous, circular dependencies can span both graphs, and tests must bootstrap two containers. Keep the Laminas container as an implementation detail of the one vendor library that requires it, and forbid new application services from being registered there.
How do I bridge Laravel's container into Laminas ServiceManager?
Register delegator factories or small factory closures in ServiceManager that call Laravel's container for shared dependencies such as the database, config, and logger. If the Laminas library needs to resolve Laravel-managed services, bind Psr\Container\ContainerInterface in Laravel to an adapter that delegates to the ServiceManager. Keep the direction of resolution explicit and avoid bidirectional auto-wiring. Test the bridge with the exact service names the library requests.
What are factories, abstract factories, delegators, and aliases in ServiceManager?
Factories create a service by name, while abstract factories can match many names and impose O(n) discovery cost per lookup. Delegators wrap or decorate an existing service, and aliases map alternate names to the same service. The shared_by_default setting controls whether resolved services are reused. These concepts are ServiceManager-specific and do not map one-to-one onto Laravel's container vocabulary.
Does laminas-servicemanager support PSR-11 and container-interop?
Yes. It is PSR-11 compatible, continuing the container-interop lineage, so get() and has() behave as other PSR-11 consumers expect. That compatibility makes a Laravel bridge feasible. PSR-11 does not provide Laravel features such as contextual binding, facades, or the service-provider lifecycle, so interop alone is not a reason to adopt ServiceManager.
When are Laminas plugin managers useful in a Laravel application?
Plugin managers, which extend AbstractPluginManager and validate with $instanceOf, are useful for homogeneous object families such as validators, formatters, or handlers. Laravel has no first-class equivalent for that pattern. They add Laminas-specific configuration and validation, so use them only for the library that requires them rather than as general application architecture.
Are Lazy Services in Laminas ServiceManager safe to use with Laravel?
Lazy services require a proxy library such as ocramius/proxy-manager or an equivalent, and they add AOP-style proxies that can obscure stack traces. They can help with expensive services, but they complicate debugging and add PHP-version constraints you must own. Prefer Laravel deferred providers or closure bindings unless the dependency specifically requires lazy proxies.
How do I test a Laravel app that uses Laminas ServiceManager?
Bootstrap the bridge in your test case and register only the services under test, then assert behavior through interfaces or concrete classes. Avoid booting two full dependency graphs when a focused test will do. Include tests for missing services and circular dependencies, because dual-container failures are difficult to diagnose.
What are alternatives to Laminas ServiceManager in a Laravel app?
For application code, use Laravel's Illuminate\Container and service providers; if you only need PSR-11 interop, a small adapter is usually enough. PHP-DI, Symfony DependencyInjection, and League Container are credible alternatives, but they also introduce a second container. Choose ServiceManager only when you need Laminas plugin managers, delegators, or abstract factories. Its release cadence follows Laminas volunteer maintainership, so pin a release and check PHP compatibility.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource