Urgent.News

What's breaking now, across thousands of outlets.

More in Tech

Introduction

Over the time, PHP and its various tools have become more advanced and easier to use. As a result, you can create your own framework even using core PHP.

Part 01 - Directory Structure of the Application

Source Code Files of this Chapter project-root/ │── public/ │ └── app/ See the final project directory structure project-root ├── app/ │ ├── Controllers/ │ │ ├── Api/ │ │ │ └── UserController.php │ │…

  • Project-root folder contains subdirectories: public, app, config, database, vendor
  • App directory stores project-related classes following MVC pattern and PSR-4
  • Public directory holds default accessible file, config contains app.php, database.php, mail.php

Part 02 - Front Controller (index.php) File

Source Code Files of this Chapter: project-root/ └── public/ └──index.php # new file Front Controller Design Pattern Front controller is a central (obviously a single) entry point to handle incoming…

  • Implement Front Controller pattern with index.php file in public directory
  • declare(stricttypes=1) enforces strict type checking for PHP file
  • echo statement displays welcome message on browser screen

More from Saturday 26 September →