What is a route?

A route is a url pattern. It is mapped to a handler.

A handler can be

  • a file on disk.
  • a class/object that fetches
    • data, or
    • a file

How can you define it?

We need a Route class. In which we need to specify:

  • A URL pattern
  • A handler
  • (and optionally) a route name.

We also need to register this route. Registration is done by adding route object to Routes collection. This route collection is of type RouteCollection and a property named Routes in RouteTable.

Reference