Kyle Thomas Kyle Thomas - 22 days ago 5
PHP Question

Mvc Routing - Friendly URL's

From reading up on MVC, I want to steer away from using Requests from client-side scripts and focus on a main router.

From research, urls look something like this:

However, when looking at StackOverflows and other similar frameworks it looks more like this:

Can someone please explain what is happening in this that's different? 1365260 looks like the users ID & example is his username so these must be the params and users is clearly the controller.

How does this framework know what action to run? Ie: search, view, update


This is not actually


You can define anything as a route.

From laravel framework perspectives- Whenever you visit a URI the framework by default redirects your request to a index page where it checks your URI in the routes list. Where each route is bound to a controllers method which handles your request. This method could do anything like search, view, create, update, delete etc.

In this routing system you can also pass parameters. Here in your example

this route is defined in routes list and a method is bound with it and user id, user name these are parameters. Whenever this route is visited it runs the method and it shows the profile of the user id and user name it gets from the route parameter.

Hope this helps.