Working on a small php MVC project and I got stuck trying to retrive the values from the url (think of id's and such). I am trying to get this values inside each controller method as method parameters but not sure if this is done easily or that I must get them directly inside each controller instead. As an example I have included the ProductController class.
example.com/post/349
example.com/user/4
example.com/product/4231
Files
// core controller class (not doing anything atm)
namespace Core;
class Controller
{
// nothing here for now
}
// product controller class
namespace App\Controllers;
use Core\{Controller, View};
class ProductController extends Controller
{
public function index(int $id = null)// I want to go this way
{
// use id value here or not
// render page
}
public function edit(int $id)
{
// use id value here
// render page
}
}