This is: Page num 2 based controller (MVC)
This tutorial is built in parts, it is imperative to start from the begining, so it will be easier to understand the processes on this framework, since every part rely on the previous part. This demonstration is based on the files designated on "Files in use" in the middle of this page. to complete our knowledge it is recommended to look for the documents on limbercode.com
All requests method such as: GET,POST,DELETE and UPDATE are being catch by the controller, we can use them as shown in this demo. on the url we added: ?width=40&height=80
after the http address of this page to simulate "GET" request. on the controller (file number 2) declaration for this page we catch the parameters: public function pageNum2BasedController($width,$height...
. the parameters can be disordered and the controller will get them by name. we now can print the parameters we catch on "view" (file number 1) with the function: p($this->width);
. this funtion will help us to print on screen (and log file) any value we want to, even array and objects.
width param:
||—————T2: $content——————————————————||
[String ] => string(2)40 /var/www/html/limbercode.com/architecture/application/views/firstPageBasedController/pageNum2BasedController.php On Line 19||——2024-12-23 01:41:54——
||—————T2: $content——————————————————||
[String ] => string(2)80 /var/www/html/limbercode.com/architecture/application/views/firstPageBasedController/pageNum2BasedController.php On Line 21||——2024-12-23 01:41:54——
We can also print all the catches params by the router, like: GET, POST, PUT, DELETE, PATCH and ect... with
the function: router::getAllParams()
||—————T2: $content——————————————————||
(1) Array - ((3) [GET] : Array - ()[)q ] => string(49)/firstPageBasedController/pageNum2BasedController
[height ] => string(2)80
[width ] => string(2)40 /var/www/html/limbercode.com/architecture/application/views/firstPageBasedController/pageNum2BasedController.php On Line 27||——2024-12-23 01:41:54——
We can validate the user/client inputs with the "validation" class, like this:
$validation = basic::load("validation","functions");
$width = isset($width['GET']) ? $validation->validate($width['GET'],"int",10,"required","width") : false;
$height = isset($height['GET']) ? $validation->validate($height['GET'],"int",10,"required","height") : false;
On the controller declaration we can load dependencies. we will want to load the dependencies only after we
catch the requests and not before them, if not code malfunctions may occur. in this demo we declared: public
function pageNum2BasedController($width,$height,dependencyDemo $dependency) {
that means that we
want to use the dependency file (file number 6), we can call it's function like this: $dependency->calculateArea($width['GET'],$height['GET'])
passing the width and height, we can calculate the "area".
calculated area:
||—————T2: $content——————————————————||
[String ] => string(11)3200 pixels /var/www/html/limbercode.com/architecture/application/views/firstPageBasedController/pageNum2BasedController.php On Line 50||——2024-12-23 01:41:54——
In case of a bad input on the url, let's say that we changing the width in the browser url to a word instead
of number or delete the width completely. a notification will pop up to inform us we have a problem. first
we load the notif class object $notif = basic::load("notif","core");
and then we choose the
notif file and number to show $notif->genNotifByNum("demo",12345);
.
Files in use: (not including template files)
1 - View (a must): architecture/application/views/firstPageBasedController/pageNum2BasedController.php
2 - Controller (a must): architecture/application/controllers/firstPageBasedControllerController.php
3 - Model (optional): architecture/application/models/firstPageBasedControllerModel.php
4 - Model data (db like) (optional): source/data/demonstrationData/main.php
5 - Css (optional): public/css/demo.css
6 - Dependency (optional): architecture/application/controllers/dependencyDemo.php
7 - Notification (optional): source/text/notifs/en/demo.php
8 - Translation (optional): source/text/translations/xx-xx/demo.php
Navigate:
homePage - Home page
firstPageBasedView - First page based "view" firstPageBasedViewMu - For multi language support
pageNum2BasedView - Page number 2 based "view" pageNum2BasedViewMu - For multi language support
firstPageBasedController - First page based "controller" firstPageBasedControllerMu - For multi language support
pageNum2BasedController - Page number 2 based "controller" pageNum2BasedControllerMu - For multi language support