PHP-DI / Slim-Bridge

PHP-DI integration with the Slim framework
http://php-di.org/doc/frameworks/slim.html
MIT License
176 stars 38 forks source link

Container resolution failing #54

Closed Maadtin closed 4 years ago

Maadtin commented 4 years ago

Hello im having a problem calling the controller class and and a method, basically Slim throws an error sayings Cannot call index on App\Controllers\HomeController because it is not a class nor a valid container entry However in the docs it says It can be called like this [Controller::class, 'some_method'

My code is the following.

use App\Controllers\HomeController;
use DI\Bridge\Slim\Bridge;
use DI\Container;

require 'vendor/autoload.php';

//$container = new Container();

$app = Bridge::create();

$app->addBodyParsingMiddleware();
$app->addRoutingMiddleware();

$app->get('/', [HomeController::class, 'index']);

$app->addErrorMiddleware(true, true, true);

$app->run();

Im using slim v4 and php-di v3

and ofcourse my HomeController has a public method called index. So what could be happening? any ideas? please help <3, thanks!

Maadtin commented 4 years ago

I needed to re-run composer dump autoload Sorry! closing this.