Urgent.News

What's breaking now, across thousands of outlets.

Tech

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 │ │ ├── AuthController.php │ │ ├── EmailVerificationController.php │ │ ├── HomeController.php │ │ └── UserController.php │ ├── Core/ │ │ ├── Abstract/ │ │ │ ├── Migration.php │ │ │ ├── Model.php │ │ │…

In this chapter, we will explore the directory structure of the application project. The project-root/folder will contain several subdirectories such as public, app, config, database, and vendor. The App directory will be used to store all project-related classes, following the MVC pattern and employing PSR-4 through Composer for class autoloading.

The public directory will hold the default accessible file of the project, while the config directory will contain various configuration files, including app.php, database.php, and mail.php. Additionally, the project will have a database directory to store migration and seeder files, as well as a vendor directory for third-party dependencies.

To begin, we will create the project-root directory, followed by the public and app subdirectories within it.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

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 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

Part 03 - Bootstrap

Prepare Runnable Environment by Loading Common Dependencies When a client’s request comes to the front controller, we want to pass the request through a middle layers instead of directly starting the…

  • Bootstrap sets up PHP web app environment
  • Creates Bootstrap.php with strict types and config
  • Integrates Bootstrap into front controller

More from Saturday 26 September →