symfony/options-resolver
Symfony OptionsResolver is array_replace on steroids: define required options, defaults, allowed types/values, normalizers, and validation for robust option/config handling in your PHP code. Great for APIs, components, and reusable libraries.
config() system, and validation layers.symfony/options-resolver (v8.1.0).^8.0 remains stable for PHP 8.4+.app()->singleton(OptionsResolver::class, fn() => new OptionsResolver());
| Risk Area | Mitigation Strategy |
|---|---|
| Version compatibility | No action needed: v8.1.0 is backward-compatible with v8.0.x. Lock to ^8.0 in composer.json. |
| Performance overhead | Unchanged: Benchmarking still applies to high-traffic services (e.g., API gateways). |
| Learning curve | No change: Internal docs remain sufficient for Laravel-specific examples. |
| Deprecation warnings | No change: setDeprecated() usage unchanged. |
| Nested resolver bugs | No change: Unit tests for edge cases (e.g., null values) still required. |
| PHP version constraints | Updated: CI/CD now enforces PHP 8.4+ for Laravel 11 compatibility. |
config() calls—unchanged)Log facade)array_replace_recursive logic? (Unchanged)ResolverService trait? (Unchanged)InvalidArgumentException or throw_if)HttpClient, Messenger).MockFacade.| Phase | Action | Tools/Examples |
|---|---|---|
| Assessment | Audit top 5 misconfigured services (e.g., queue workers, API clients). | grep -r "array_replace" app/ + support ticket analysis. |
| Pilot | Replace manual validation in 1–2 services with resolvers. | Example: PaymentGatewayService → PaymentGatewayResolver. |
| Core Integration | Bind OptionsResolver to Laravel’s container and create base resolver trait. |
app()->singleton(OptionsResolver::class, ...) + ResolverAwareService. |
| Validation Layer | Add resolver validation to ServiceProvider boot methods. |
boot(): $this->validateServiceConfigs($resolver). |
| Deprecation | Use setDeprecated() for legacy configs and log warnings. |
ResolvedEvent listener for deprecation notices. |
| Testing | Write unit tests for resolver schemas and integration tests for services. | ResolverTestCase trait + ServiceTestCase. |
| Documentation | Publish internal docs with Laravel-specific resolver patterns. | Markdown guide + README.md in app/Config. |
| Scaling | Extend to third-party packages and custom packages. | composer.json require + config/resolver.php for shared schemas. |
| Component | Compatibility Notes |
|---|---|
| Laravel 11 | Full support (PHP 8.4+). |
| Laravel 10 | Use ^7.4 (PHP 8.2+). |
| PHP 8.4 | Required for Symfony 8.1.0. |
| Symfony Components | Works with HttpClient, Messenger, Validator, etc. (Symfony 8.1.0). |
| Custom Packages | Define resolver schemas in config() or package service providers. |
| Legacy Code | Use setDeprecated() for gradual migration of array_replace logic. |
| Testing Frameworks | Compatible with PHPUnit, Pest, and Laravel’s MockFacade. |
ServiceProvider boot methods.NotificationService).config() caching with resolver validation).setDeprecated() provides automated warnings.^8.0 for minor updates.config('resolver.schemas')).| Failure Scenario | Mitigation |
|---|---|
| Resolver schema misconfig | Descriptive errors + unit tests for schemas. |
| Circular references | Unit tests for nested structures. |
| PHP 8.4+ requirement | CI/CD checks enforce PHP 8.4+ before merging. |
| Third-party package conflicts | Isolate resolvers per package (e.g., config/resolver.php). |
| Performance bottlenecks | Benchmark high-traffic services (e.g., API gateways). |
NO BREAKING CHANGES in v8.1.0; assessment remains valid with PHP 8.4+ and Laravel 11 updates.
How can I help you explore Laravel packages today?