bolt/bolt — pull request #1187 by rossriley (2014-05-15 13:30:30+00:00)
Title: Experimental resource config

For Discussion / Feedback - Not Ready for the wild yet.

This is an attempt to add configurability and a lot more flexibility to where the application resources are stored. It's seeking to solve the current problems...

1. Getting bolt running under composer has quite a few problems, this makes all configurations equally valid.
2. It should be easy to get bolt running in a non-public directory.
3. It's difficult currently to get bolt running under a Stackable(stackphp) architecture since a lot of URLs are hard-coded, main cuplrits are async, thumbs
4. It would be nice to simplify the bootstrap process and use objects rather than constants to get an app setup
5. All of the above will help in testing where you want to sandbox or mock a lot more of the path locations.

This initial version aims just to replace the functionality provided currently by the defined constants, eg. `BOLT_WEB_DIR` `BOLT_CACHE_DIR` `BOLT_CONFIG_DIR` etc. and the global function `getPaths()`

There is a default class `ResourceManager` but flexibility to extend this to create many more configurations for example, also included in the pull request is `ComposerResources` which extends the defaults but overrides wherever necessary to change the defaults.

Bootstrapping an application should then be possible without the bootstrap.php file and would look something like this, where `__DIR__` represents the project root directory

```
$app = new Bolt\Application();
$config = new Bolt\Configuration\ResourceManager(__DIR__, $app);
$config->initialize();
$app['resources'] = $config;
$app->initialize();
```
The configuration can easily be adjusted:

```
$config = new Bolt\Configuration\ComposerResources(__DIR__, $app);
```
or:
```
$config = new My\Custom\ResourceConfigurator(__DIR__, $app);
```

There is then a central resource point that will need to be referred to across the app to consume this manager, eg twig templates can use for example `app.resources.getPath('filespath')` or controllers can use for example `$app['resources']->getUrl('currenturl')`

For simplicity there is also `$app['resources']->getPaths()` which is designed to be compatible with the current global function getPaths().