如何将Pleague v2.4 与Slim v3.8.1 一起使用?
按照这个例子,我尝试了:
// PSR 7 standard.
use Slim\Http\Request;
use Slim\Http\Response;
// Import classes.
use Slim\App as Slim;
use League\Container\Container;
$container = new Container;
// Required to enable auto wiring.
$container->delegate(
new \League\Container\ReflectionContainer
);
// Get an instance of Slim.
$app = new Slim($container);
我得到:
致命错误:未捕获 League\Container\Exception\NotFoundException:别名(路由器)未由 /var/www/html/projectA/vendor/league/container/src/Container.php:266 中的容器管理堆栈跟踪:# 0 /var/www/html/projectA/vendor/league/container/src/Container.php(93): League\Container\Container->getFromDelegate('router', Array) #1 /var/www/html/projectA /vendor/slim/slim/Slim/App.php(239): League\Container\Container->get('router') #2 /var/www/html/projectA/vendor/slim/slim/Slim/App. php(143): Slim\App->map(Array, '/', Object(Closure)) #3 /var/www/html/projectA/public/index.php(53): Slim\App->get( '/', Object(Closure)) #4 {main} 在第 266 行的 /var/www/html/projectA/vendor/league/container/src/Container.php 中抛出
有任何想法吗?