I have followed this nice video tutorial to create a mini MVC PHP framework.
As you can see, the guy creates an action called home() inside the Controller class to show the main page.
Now, I need to create another action called foobar() that shows another page, but how can i associated it to an url in a simple way?
This is usually done by routing. If the first part of the URL identifies the controller and the second the action, you extract those variables and route accordingly.
A very basic example:
Obviously,
$actionand$controllerNameare obtained from the URL.This code snippet tries to call the method ‘foobar’ inside a class named ‘whatever’.