Closed
Description
Heavily inspired from DunglasActionBundle and ActionAutowire, I would like to suggest to integrate the following to the core:
framework:
autowiring:
# In this include statement, a list of directories can be given in which all PHP classes found
# will be registered as auto-wired services
include:
- '/path/to/dir' # can be an absolute path
- '%root.kernel_dir%/path/to/dir' # can use parameters for the path
- '@AppBundle/Http/Action' # can use the @Bundle notation
- '/path/to/dir': # can specify the directory to list as a key and then give a list of elements to filter inside it
- 'Foo.php' #regular file, equivalent to '/path/to/dir/Foo.php'
- '/.*Foo\.php/i' # can also make use of a regex
exclude: ~ # Same structure as include
# This service section works pretty much as the `services` root declaration. The services
# declared there declared as auto-wired (so no `autowire: true` required) and have a
# simplified list of properties that can be set, as the other are irrelevant for auto-wired
# services.
services:
App\FooInterface: @App\Foo # bind the App\FooInterface to the concrete class App\Foo
# Complete list of the elements accepted for an autowired service
App\Foo:
public: false
methods: # list of autowired methods
- setBar
tags: [ {name: mytag} ]
calls:
- [ setFoo, ['foo'] ]
This would help a lot to work with autowiring, trigger it as a default in specific places of your application, and ease the service registration for auto-wired services instead of having the classical one which is a bit cumbersome.
WDYT?