Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind method on Silex

Tags:

php

routes

silex

I couldn't find it anywhere. So I ask: On silex, why do we use bind() for? For example, on this routing of static pages:

$pages = array(
    '/'      => 'index',
    '/blog'  => 'blog',
    '/about' => 'about',
);

foreach($pages as $route => $view) {
    $api->get($route, function(Silex\Application $app) use($view) {
        return $app['twig']->render($view.'.html');
    })->bind($view);
}
like image 697
Danilo Lima Avatar asked Apr 20 '26 10:04

Danilo Lima


1 Answers

For an event-heavy framework, it's a bit of a poor choice, but this basically names the route.

Things like providers can get access to the routes if they are given a name.

Relevant documentation:

  • http://silex.sensiolabs.org/doc/usage.html#named-routes
like image 138
Evert Avatar answered Apr 23 '26 01:04

Evert