How to create a proper routing system for a no-framework PHP web application?

475 Views Asked by At

I am a beginner in PHP development, and I have recently been asked to create a small web application from scratch. I did some research and I decided that I DO NOT want to use any framework, because I truly want to learn how to create decent code myself.

The thing is, I am creating a basic MVC structure to generate a basic CRUD for a model that I have, but I am totally clueless about the best practices to get clean, useful URLs for my application.

I am running on Ubuntu 16.04 LTS, using Apache as a webserver with PHP 5.6 and MySQL. My first idea was to redirect all the requests through index.php and arrange some sort of mechanism in an .htaccess file to rewrite ugly URLs into more friendly and simpler ones, but to be honest, I do not even know where to begin with.

How am I supposed to handle the requests in my index.php file to redirect the user to the proper Controller and do the required action in there? Am I taking the right path regarding this?

0

There are 0 best solutions below