I am busy learning as much as I can about php frameworks.
At the moment I have a file full of routes. The routes take this general form.
$bootstrap->router->add('/home', ['controller' => 'home', 'action' => 'index']);
So, the 'routes' file is not a class, it is just a file which I include into the index.php page just underneath $bootstrap = new Bootstrap($router);
.
As you can see, to add a route I add it to the instantiated $bootstrap object, which itself has an instantiated ->router object inside which I am calling the 'add()' method.
Now I want to make it easier to add routes by writing something like this...
route('/home', ['controller' => 'home', 'action' => 'index']);
question
Exactly how to go about this is unclear... I am not even sure if this is a done thing. I have tried making a 'helpers/RoutesHelper file' but that takes my request out of the object scope...
...so I am a bit confused, how do I go about implementing a plane old helper function inside object oriented code?
Many thanks in advance.