fabpot/Silex — Issue #184: GET "/" in a ControllerCollection
Author: fredr
Created: 2011-10-10 11:35:23+00:00
State: open

When adding a ControllerCollection, and mounting that to let's say /test and the adding a path to "/" in that ControllerCollection, I get ```NotFoundHttpException: No route found for "GET /test/"``` when trying to access www.addresstomy.app/test/

But when I add a path, lets say /yes to my ControllerCollection, accessing www.addresstomy.app/test/yes will work

I've put together a little test below, it's been tested on f400c25 and 535c1cb, accessing /test works fine in f400c25, but not in 535c1cb

If I remove the "/" route that is defined in index.php (www.addresstomy.app/) below, /test/ will work in the new version of silex as well.

Working version
Silex version f400c25 2011-09-22 11:05:30 +0200

Non working version
Silex version 535c1cb 2011-10-09 11:28:30 +0200

This is my example app

index.php

$app = new Silex\Application();
require_once __DIR__ . "/TestControllerProvider.php";

$app->get("/", function() use($app) {
return "this breaks it..";
});

$app->mount("/test", new Test\TestControllerProvider($app));

TestControllerProvider.php

namespace Test;

use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;

class TestControllerProvider implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = new ControllerCollection();

$controllers->get("/", function() use ($app) {
return "this wont work";
});

$controllers->get("/yes", function() use ($app) {
return "this will work!";
});

return $controllers;
}
}