I have a project that use Silex 1.2 in addition to updating to version 2. But mounting routes dynamically in a controller no longer works. My new routes are not saved.
// routing.php
$app->get('/', 'App\\Controllers\\App::main')->bind('app_main');
// App.php
class App {
function main(Application $app, Request $request) {
$name = 'basic';
$version = 1;
$moduleClass = 'App\Core\Modules\\'.$name.'\v'.$version.'\\ControllerProvider';
$app->mount($request->getPathInfo(), new $moduleClass($name, $version));
$subRequest = Request::create(
$app['url_generator']->generate('basic_1'),
'POST'
);
return $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false);
}
}
And my application can not find the new route, this code work with Silex 1.2... I can not find what has changed in version 2.