zazoomauro / node-dependency-injection

The NodeDependencyInjection component allows you to standarize and centralize the way objects are constructed in your application.
https://github.com/zazoomauro/node-dependency-injection/wiki
MIT License
280 stars 34 forks source link

Ability to override services from autowire #213

Closed zazoomauro closed 2 months ago

zazoomauro commented 3 months ago

If you're using the default services.yaml configuration both classes are automatically registered as services and configured to be autowired. This means you can use them immediately without any configuration.

However, to understand autowiring better, the following examples explicitly configure both services:

# config/services.yaml
services:
    _defaults:
        autowire: true

    App.Service.TwitterClient:
        # redundant thanks to _defaults, but value is overridable on each service
        autowire: false
        arguments:
          - @App.Twitter