Silex-Bridge
Silex-Bridge copied to clipboard
Can't seem to get this working w/ the latest version of Silex.
Created a generic test class and tried to let PHP-DI do it's thing and it just errors out:
example code:
$container = include __DIR__ . '/container.php';
$app = new DI\Bridge\Silex\Application($container);
$app['debug'] = true;
$app->get('/', [\TMI\Test::class, 'example']);
return $app;
Error:
InvalidArgumentException in ControllerResolver.php line 54:
Controller for URI "/" is not callable: Cannot call example on TMI\Test because it is not a class nor a valid container entry
in ControllerResolver.php line 54
at ControllerResolver->getController(object(Request)) in HttpKernel.php line 136
at HttpKernel->handleRaw(object(Request), '1') in HttpKernel.php line 68
at HttpKernel->handle(object(Request), '1', true) in Application.php line 496
at Application->handle(object(Request)) in Application.php line 477
at Application->run() in index.php line 4
Hi, is TMI\Test a class?
Yeah, was just a simple class eg.:
namespace TMI;
class Test
{
public function example()
{
return 'example';
}
}
Was testing autowiring, just doesn't seem to work.
Was is configured with Composer? Can you try by embedding it in the whole script just to be sure? Like this:
$container = include __DIR__ . '/container.php';
$app = new DI\Bridge\Silex\Application($container);
$app['debug'] = true;
class Test
{
public function example()
{
return 'example';
}
}
$app->get('/', [Test::class, 'example']);
return $app;
It should work so really I'm shooting in the dark trying to understand ;)
Yeah it was setup w/ PSR-4 autoload setting. When I get a chance today I'll double check my setup and post it.
Just to confirm I'm using silex 2.0.x + php-di silex bridge 2.0.0-beta1