Posted by router:
class App { private $fileOrderManager; private $pageManager; private $routes = [ '/' => 'getIndex', '/admin' => 'getAdminPage', '/order' => 'save' ]; function __construct($fileOrderManager,$pageManager) { $this->fileOrderManager=$fileOrderManager; $this->pageManager= $pageManager; } public function run() { $path = parse_url($_SERVER['REQUEST_URI']); $method = $this->routes[$path['path']] ?? 'getIndex'; if(!method_exists($this, $method)) { return; // throw exception } $this->$method(); $this->pageManager->getIndex(); $this->pageManager->getAdminPage(); $this->fileOrderManager->save(); //$this->fileOrderManager->list(); } } Obviously, in this form, the method does not find it, the condition method_exist works and returns from the function. How do I set up to call methods from classes ($ this-> pageManager-> getIndex (); and mn)?
Thank!