I am watching the teaching video
The red line is output to the front-end page, and it does not say which template it is. The specified template page is indeed accessed in the video. Is it done through @Route (name="page_index"), but I don't see his front-end page using this name. I wonder how to access the specified page?
Question 2: If two paths are defined as ‘/’ in app/confing/routing but the accessed controllers are different, then when I access the address localhost:8000, which page will I access? How to distinguish if you want to distinguish?
After declaring @Template(), you don’t need to write the path in the return. It will be automatically searched. For example, as mentioned above, the indexaction of defaultController is the Resources/views/Default/index.html.twig path
I have used version 1.2, which is very old. Let me tell you my experience with that version:
The template is not made through route. Route only controls which action of which controller you access. The specific definition of which template is in the controller. Although there is no way to define the board in the above code, it will have a default view. Yes, the actionnameSuccess.php file in 1.2. If you wonder how it is accessed, you need to look at the source code. There will be a default implementation.
The routing in question 2 defines two controller actions corresponding to
/
, 他会从上向下查找, 一旦请求的url满足了某个规则, 则直接跳转到对应的controller, 相同routing规则的第二个配置就找不到了, 所以你的第二个/
并没有什么卵用,localhost:8000 默认会指向default的controller和action, 在routing的最后会有这个默认配置, 但你这个/
配置是否会影响, 你得看的配置是怎么配的了,有可能你的这个配置满足了默认页面的请求url规则, 会跳转到你的/
at the same time. It may not be satisfied and the default controller action is still used.The default template is placed in
Resources/views/{your controller name}/{your action name}.html.twig
For example:
DefaultController’s indexAction
The default template is in
Resources/views/Default/index.html.twig
Note that Linux is case sensitive.
You can also specify the path, annotation:
@Template("your/view/path")