Skip to content

Instantly share code, notes, and snippets.

@davedevelopment
Created March 6, 2013 14:31
Show Gist options
  • Save davedevelopment/5099669 to your computer and use it in GitHub Desktop.
Save davedevelopment/5099669 to your computer and use it in GitHub Desktop.
<?php
class FooConverter
{
public function convert($value) {}
}
$app = new Silex\Application;
$app['converters.foo'] = function($value) {
$converter = new FooConverter(); // or could pull from container if dependencies are required
return $converter->convert($value);
};
$app->get("/foo/{foo}", function($foo) {
})->convert("foo", $app['converters.foo']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment