symfony/symfony — pull request #11059 by lavoiesl (2014-06-04 19:44:27+00:00)
Title: [DependencyInjection] [Routing] [Config] Recursive directory loading

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #11045
| License | MIT
| Doc PR | TODO

See those about creating a cookbook for better file organization:
Issue: symfony/symfony-docs#3680
PR: symfony/symfony-docs#3885

This PR allows to specify a directory to load and it will recursively load all file from it, using the `LoaderResolver`.

### Example
```yml
# app/config/config.yml
imports:
- { resource: 'dev/' }
```

```
└── app
├── config
│ ├── common
│ │ └── framework.yml
│ │ └── assetic.yml
│ └── config.yml
```

It also works for routing configuration:
```yml
_common:
resource: "common/"
type: directory
```

### Conflicts
For now, the Routing DirectoryLoader requires the type `directory` to be specified so it does not conflict with `AnnotationDirectoryLoader`. However, this could be refactored.

The type declaration requires a [patch in AsseticBundle](https://github.com/symfony/AsseticBundle/commit/f76291c4655f6b7b29f4d20650c020d3be516ad5) for it to be used on `framework.router.resource`. The patch is already merged in master, but not in a release yet. When it is, changing the main router would be like this:

```yml
framework:
router:
resource: "%kernel.root_dir%/config/routing/common/"
type: directory
```