Symfony不显示默认控制器

时间:2017-03-20 03:42:26

标签: php symfony web

所以sensio labs有这个例子: http://symfony.com/doc/current/quick_tour/the_controller.html

class DefaultController extends Controller
{
    /**
     * @Route("/hello/{name}", name="hello")
     */
    public function helloAction($name)
    {
        return $this->render('default/hello.html.twig', array(
            'name' => $name
        ));
    }
}

我想做类似的事情就像我的样子。

class DefaultController extends Controller
{
    /**
     * @Route ("/", name ="home page")
     */
    public function indexAction()
    {
      return $this->render('default/index.html.twig');
    }
}

但是当我加载页面时,它不起作用http://sfsuse.com/~sp17g01/sp17g01/web/

index.html.twig文件应该是它的位置。

1 个答案:

答案 0 :(得分:0)

  

由于默认的app.php使用prod配置,你需要先确保清除缓存,但要么运行php bin / console cache:clear --env = prod首先从项目根目录,或者通过从项目根目录执行rm -rf var / cache来手动清除缓存目录。或者,您可以通过执行sfsuse.com/~sp17g01/sp17g01/web/app_dev.php/hello/danny来访问它,但是您需要更新安全规则以允许从该文件上的IP进行访问

<强> Augwa