Routing
Routing is a key part of setting up our blog and was discussed in detail in the previous chapter, Chapter 8, Creating Custom CMS Pages. We will therefore go on to create hardcoded routes, going directly to the routing.yml
file to modify this.
Let's create a set of rules that are needed in order to identify articles, categories, and author pages. In addition, we want pages to be accessed by using either our ID or our slug.
As an example, we report the two routing rules related to the article, in this following piece of code:
blog_article_by_id: path: /blog/article/{page} controller: BlogBundle\Controller\BlogController:articleAction requirements: path: '.*?' page: '\d+' blog_article_by_slug: path: ...