In the previous chapter, we have gained a better understanding of the role the database
class plays in the project, which is used every time the developer interacts with the database.
The only library that we used is called Whoops, which will show errors in a readable format. We also gained experience building default states, including baseController
and baseMethod
.
In this chapter, we will be focusing on the security aspect of the project, that is, authentication. We will be building login forms which interact with the database to verify the identity of the users. Finally, we will cover how to set up a password recovery mechanism in our application.
By the end of this chapter, you will be able to:
In this section, we will continue to build features on top of the framework. The core framework system files are in place. This setup is used to build useful features on top of this.
We will build the authentication system and complete the application build. Authentication is required to prevent access to unauthorized users. This ensures only the users with a valid username and password can log in to our application.
Relative paths are paths that are relative to the current folder path, for example, ./css
points to a relative path one folder up and into a css
folder.
Absolute paths are the full path to a file or folder, such as /user/projects/mvc/css.
This is important as this will allow files to be included using an absolute path anywhere in the framework system. This is an adaption to existing code in the system.
For example:
$filepath = "../app/views/$path.php";
This becomes:
$filepath = APPDIR."views/$path.php";
This builds on the current concept and allows views to be organized into subfolders. Without this adaptation, it will not be possible to organize anything into subfolders and it will interfere with keeping a tidy organization of code.
It is possible to continue building the system without these changes, but it is always a good idea to make sure code is tidy and organized.
Layout files are required so that any error can be displayed.
In addition, layout files are required for the header
, footer
, and navigation
. Once created, these file will provide elements that should be brought in across the application. This will include global elements.
Errors are for validation, and this is to be covered in a further subsection and not to be confused with parse errors or similar from the errors seen previously. The errors these steps are concerned with are errors related to form validation where a user inputs the incorrect information into form fields.
Bootstrap is a HTML, CSS, and JavaScript library, and will be included for the purpose of this chapter to give a basic level of styling. It is useful for a developer as it can help them prototype and visualize how their application will look before the designer adds the design elements to an application.
In this project, Bootstrap will be included in the header as a content delivery network (CDN). A CDN takes resources that are very commonly found on the web and caches them to help boost performance.
This can be easily confused with bootstrapping a framework.
Bootstrap, the HTML, CSS, and JavaScript library, and the concept of bootstrapping are two different things that share a similar name.
You can find more information on Bootstrap by visiting the following link: https://getbootstrap.com/.