1

I have a webpage that fetch product data from arrays and print all type of products like the example given below.

enter image description here

I want to use routing if it is useful for this case. i saw some example code like below:

class Controller {
    public $model;

    public function __construct()  
    {  
        $this->model = new Model();

    } 

    public function invoke()
    {
            // show the requested products
            $products = $this->model->getList($_GET['type']);
            include 'view/viewlist.php';

    }
}

I am learning custom MVC in php and finding the benefits of routing in this example.

How can I use routing for getting product list.

James Z
  • 12,209
  • 10
  • 24
  • 44
user5005768Himadree
  • 1,375
  • 3
  • 23
  • 61
  • 1
    You will find the answer in [here](https://stackoverflow.com/questions/18727186/how-to-load-classes-based-on-pretty-urls-in-mvc-like-page). I suggest you to follow the advice from the part _"What people actually use professionally?"_. My favorite library is [FastRoute](https://github.com/nikic/FastRoute). It is easy to understand how it does the routing. Good luck. – PajuranCodes Jul 21 '18 at 20:09

0 Answers0