Download the PHP package bite/service-discovery without Composer
On this page you can find all versions of the php package bite/service-discovery. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bite/service-discovery
More information about bite/service-discovery
Files in bite/service-discovery
Package service-discovery
Short Description Attribute based service discovery for Nette DI.
License MIT
Informations about the package service-discovery
Service Discovery
Attribute-based service discovery for Nette DI Container.
Simplify your application configuration by automatically discovering and registering services based on:
- Class type (parent class)
- PHP 8 attributes
Installation
Bootstrap Hook
Add this hook to your Nette Bootstrap.php:
Configuration
Register the extension in your common.neon file:
Service Discovery by Class Type
Define discovery rules in your service.neon:
All classes in %appDir%/Controls and %appDir%/Model matching these criteria will be automatically registered. Discovery by implementing interfaces is by design not possible.
Service Discovery by Attribute
Event Listener Discovery by Attribute
Require mildabre/event-dispatcher. package.
Services with this attribute are automatically tagged with event.listener tag and added by mildabre/event-dispatcher to EventDispatcher.
Exclude Service from Discovery
Class excluded from auto-registration can still be instantiated manually via constructor, without relying on setter injection.
Important: Manually-registered services in services.neon are not affected by the attribute!
Lazy Services
Native PHP 8.4 lazy services are supported and can be enabled per discovery configuration:
When disabled, lazy initialization is not used and PHP 8.1+ is sufficient:
Individual services registered via #[Service] attribute can override the global lazy setting:
Enable Inject mode by Class Type
Enable Inject mode by implementing interfaces is by design not possible.
Migration from Search Section
Before:
After:
Go Event-Driven
Service Discovery is a natural foundation for event-driven architecture. Pair it with mildabre/event-dispatcher - simple EventDispatcher that brings modern architecture possibilities.
- automatic listener discovery
- zero manual wiring
- clean separation of concerns
A worthy plugin for modern Nette-based applications.
Requirements
- PHP 8.1 or higher
- Nette DI 3.1+
- Nette Schema 1.2+
- Nette RobotLoader 4.0+
License
MIT License. See LICENSE file.
All versions of service-discovery with dependencies
nette/di Version ^3.2
nette/schema Version ^1.3
nette/robot-loader Version ^4.0