Weave Code
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

Di Laravel Package

nette/di

Nette DI is a fast, configurable dependency injection container for PHP. Compile-time container generation boosts performance, while extensions, autowiring, and service definitions make complex apps easy to wire. Integrates smoothly with the Nette framework or standalone.

View on GitHub
Deep Wiki
Context7

💎 Flexible, compiled and full-featured Dependency Injection Container with perfectly usable autowiring and support for all new PHP 8 features.

Frequently asked questions about Di
Can I use nette/di as Laravel’s primary dependency injection container?
No, nette/di is not designed for Laravel’s ecosystem. Its compiled container architecture conflicts with Laravel’s runtime binding system (e.g., service providers, facades). Use it only for non-Laravel components via PSR-11 adapters like league/container.
How do I install nette/di in a Laravel project?
Run `composer require nette/di` in your project root. Avoid direct integration with Laravel’s container; instead, use it for standalone services or wrap it with a PSR-11 adapter for compatibility.
Does nette/di support Laravel’s service providers (register/boot methods)?
No, nette/di lacks Laravel’s service provider lifecycle hooks. You’d need a custom ServiceProvider to manually sync nette/di definitions with Laravel’s container, which adds complexity.
Will nette/di work with Laravel’s facades (e.g., Cache::get())?
No, facades rely on Laravel’s container resolution methods (e.g., `app()`), which nette/di cannot replicate. Use nette/di only for services not tied to Laravel’s facade system.
Can I use nette/di’s autowiring alongside Laravel’s autowiring?
Not seamlessly. Laravel’s autowiring is runtime-based, while nette/di compiles dependencies statically. Mixing them risks unpredictable resolution, especially for circular dependencies or shared services.
What Laravel versions support nette/di via PSR-11 adapters?
nette/di works with any Laravel 8.0+ version, but integration requires a PSR-11 adapter (e.g., league/container). Test thoroughly—Laravel’s container expects runtime flexibility, while nette/di is optimized for compile-time rigidity.
How do I configure nette/di for Laravel (e.g., Neon/YAML files)?
nette/di uses Neon/YAML or PHP-based service definitions, which don’t align with Laravel’s PHP-class providers. You’d need a custom ServiceProvider to load nette/di configs into Laravel’s container, adding maintenance overhead.
Is nette/di faster than Laravel’s native container?
Yes, nette/di’s compiled container is significantly faster for static services, but this comes at the cost of runtime flexibility. If using a PSR-11 adapter, expect ~20-30% slower resolution than Laravel’s native container.
Are there alternatives to nette/di for compiled DI in Laravel?
For compiled DI, consider PHP 8.1’s native `return new self()` or Laravel’s `make:` command for optimized containers. For PSR-11 compliance, explore `league/container` or `php-di/php-di` (though neither offers compile-time performance).
How do I debug nette/di services in a Laravel app?
nette/di’s Tracy debugger won’t integrate with Laravel’s debugbar. Use custom logging (e.g., `error_log`) or wrap nette/di services in Laravel’s container for debugging via `app()->make()` or `app()->bind()`.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata