我正在Youtube上尝试基本的容器教程,我仍然坚持这一部分。我确保给出了一个twig实例而不是容器,但错误仍然出现。
继承了index.php的容器部分:
<script>
$(document).ready(function(){
$("#myform").on('submit',function(e){
e.preventDefault();
//this will stop default form submit.
});
$("#submitButton").on('click',function(e){
e.preventDefault();
//your code goes here.
});
});
</script>
routes.php文件:
$container['view'] = function ($container)
{
$view = new \Slim\Views\Twig('src/Views', ['cache' => false,]);
$view->addExtension(new \Slim\Views\TwigExtension(
$container->router,
$container->request->getUri()
));
return $view;
};
$container['loginController'] = function ($container){
return new \App\Controllers\LoginController($container->view);
};
Controller.php这样:
$app->get('/', 'LoginController:login_redirect');
答案 0 :(得分:1)
不应该$container['view']
作为构造函数参数传递,而不是$container->view?
$container['loginController'] = function ($container){
return new \App\Controllers\LoginController($container->view);
};