Closed Remo closed 11 years ago
Both 1.x and 2.0 do not support a closure to be the route target.
When you define a closure in the route, it is processed as an inline controller action. This is broken in the current 2.0 code, fixed locally, but not pushed yet.
I see! Are there lots of changes that haven't been pushed yet?
Pushed my local changes. Not properly tested, so it might still have issues.
The closure doesn't seem to be properly executed, it runs into this exception: https://github.com/fuelphp/foundation/blob/master/src/Fuel/Foundation/Request/Local.php#L144
As the exception says, a controller method (or a closure in this case) MUST return a Response object. Returning a string is not supported, 2.0 doesn't do automatic encapsulation, that was already deprecated in v1.5.
This works fine:
$router->all('test', function() { return \Response::forge('html', 'welcome/index'); });
which also shows you one of the reasons it's not supported, the Reponse object type can not be "guessed"....
makes sense, but the demo app doesn't do it this way. https://github.com/fuelphp/demo-application/pull/1 ?
that code didn't quite work for me. I've created a second pull request which works for me: https://github.com/fuelphp/demo-application/pull/2
Demo code wasn't pushed either... Which I've done now.
thanks!
there was also a change in the fuelphp package (updated index.php), which I've pushed as well.
I've installed fuelphp2 on a new ubuntu dev box and found an issue I'm not sure how to handle, my experience with fuelphp is too limited..
When I open /index.php/test/, I get this error:
The problem happens here https://github.com/fuelphp/foundation/blob/master/src/Fuel/Foundation/Request/Local.php#L184 where I get a closure object since the test route is definied like this:
I'm not sure if this still supported, I could easily replace it with a string.