I'm starting with PHP following the MVC pattern and I'm doing a website to manage products. The problem I have is that I call the controllers from different sites on the web and this generates problems for me as far as the urls. For example, I have a class, driver and view related to the products, and apart I also call the controller Products from the index.php and it gives me failures. If someone has had the same problem and / or can give me a little advice on how to use the routes in MVC, I would be very grateful. Thank you. I leave the files here: - Project structure:
- Dirs.php:
-
Index.php, I make the call to the controller, here there is no error:
-
Noticias.php, which also calls the controller to show news, as in the index.php, but since they are not in the same directory, I get this error:
-
And finally the newsController.php file, which calls the newsModel.php file to instantiate the News class:
-
And the class noticiaModel.php, which calls the class conexion.php:
In short, the problem I have is that I try to call the controller from the index and from another file in the view, and I get an error. I hope someone can help me a little because I do not know what to do. Many thanks in advance colleagues.