While working with Slim and PHP-DI, got a warning saying
Uncaught Error: Call to undefined method App\App::run()
The code is as follows:
require __DIR__ . "/../vendor/autoload.php";
$app = new \DI\Bridge\Slim\Bridge;
$app->run();
While working with Slim and PHP-DI, got a warning saying
Uncaught Error: Call to undefined method App\App::run()
The code is as follows:
require __DIR__ . "/../vendor/autoload.php";
$app = new \DI\Bridge\Slim\Bridge;
$app->run();
In latest version of PHP-DI, there are some changes
DI\Bridge\Slim\App
has changed toDI\Bridge\Slim\Bridge
. So if you are usinguse DI\Bridge\Slim\App as DiBridge;
may not work. Instead tryuse DI\Bridge\Slim\Bridge as DiBridge;
There is no
$app->run()
method defined in PHP-DI Bridge class, hence its undefined. Instead use$app->create()
method.Note
In order to use
create()
method on$app
, make sure you have slim/psr7 installed, otherwise you may see a bloody red warning. If you dont have slim/psr7 installed use the following command to get it installedcomposer require slim/psr7
So after making sure slim/psr7 is there, code must look as follows