The Controller 🎮
Up and Running 👟
Every route you specify in your application will end in the static method of a controller. Controller are PHP classes that are derived from the
Core/Controller base class.
This will look something like this:
Now, after you got your fancy new controller, we need to populate it with some methods. These methods have to be public, static and need to get a reference on a
Core/Request class instance. Like this:
Here we utilized a method already provided by the
Core/Controller parent class:
It takes the path to the template to render and an array with variables that should be available in the template.
All templates resign in
views/ of your project. FMVC will automatically start looking there so you do not have to include this folder in the path.
All your output will be printed onto the document like you are used to from PHP. So you can also just use echo or print to create your output.