stackphp/builder — pull request #2 by davedevelopment (2013-06-18 08:07:01+00:00)
Title: Allow pushing factories on to the builder

No type checking on the return of the factory, but I think it will be alright.

The use case that drove this was based on discussion in #silex-php, if I was mapping authentication schemes to certain paths, I'd want to do it like this:

``` php

$builder->push(function ($app) {
return = new UrlMap($app, [
'/api' => new Hawk($app, []),
'/admin' => new BasicAuth($app, []),
]);
})

```

I guess that could start to generate a complicated stack, but it's the way I'd roll. I think you can add express.js middlewares with an url prefix, should really check there implementation.

I can't think of any other use cases at the moment, but this would make the builder very flexible going forward and it will be a lot easier for little builder helpers as well, e.g. we could quickly decorate a builder with a `pushPrefixed` method.