Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By : Sai S Sriparasa
Book Image

Building a Web Application with PHP and MariaDB: A Reference Guide

By: Sai S Sriparasa

Overview of this book

Table of Contents (17 chapters)
Building a Web Application with PHP and MariaDB: A Reference Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up MVC


Now that we have our folder structure and the rewrite functionality working, we can begin setting up our MVC-based application. The first thing that we will have to focus on would be to bootstrap our application by loading the required classes. We are storing these required classes in the lib folder and we will use the config.php file to store the required configurations such as the location of the lib folder, the base URL for our application, and the database connection information.

<?php
define('LIBRARY', 'lib/');
define('BASE_URL', 'http://localhost/student-portal/');

define('DB_VENDOR','mysql');
define('DB_HOST','localhost');
define('DB_NAME','course_registry');
define('DB_USR','root');
define('DB_PWD','top_secret_pwd');

Let us add the Bootstrap class in our lib folder. This class will be responsible for understanding, interpreting, and redirecting the incoming request to the correct controller. The code to be entered in lib/Bootstrap.php class is as follows:

<?php...