Working with requests
As you might recall from previous chapters, the main purpose of a web application is to process HTTP requests coming from the client and return a response. If that is the main goal of your application, managing requests and responses should be an important part of your code.
PHP is a language that can be used for scripts, but its main usage is in web applications. Due to this, the language comes ready with a lot of helpers for managing requests and responses. Still, the native way is not ideal, and as good OOP developers, we should come up with a set of classes that help with that. The main elements for this small project—still inside your application—are the request and the router. Let's start!
The request object
As we start our mini framework, we need to change our directory structure a bit. We will create the src/Core
directory for all the classes related to the framework. As the configuration reader from the previous chapters is also part of the framework (rather than...