How to implement bootstraping class in PHP framework?

Hi guys, I am creating my own MVC infrastructure (please don’t reduce me because everyone wants to create a framework.) And so .. I want to make a bootstrap class, as I saw in many frameworks. I do this because I decided to go to the next level, starting to study the structure from the inside. But I face some problems going through them. But I will analyze them on various issues. Now, to clarify my question: What features should a Bootstrapping class have? And Can you give me articles that could help me?

+4
source share
2 answers

There should not be a "bootstrap class". This is a simple process that may contain a simple script that will serve as an entry point for your application. PHP is not Java, so you do not need to contain everything inside the class.

Typically, an application bootstrap script has the following responsibilities:

  • configure autoloader
  • initialize the routing mechanism
  • configure storage abstractions (db, cache, etc.).
  • handle user request (using routing)
  • sending to MVC

The bootstrap phase in your application is where all wiring between objects should be configured. It is also the place where you create things like logs, access control mechanisms, and error handling.

We can say that the front controller is part or boot.

PS: you can also find this answer of my meaning, as it also contains an example bootstrap file.


List of Recommended Products:

The last two links cover two of the three main MVC-based patterns (Model2 MVC and MVP), since classic MVC is actually very impractical (and almost impossible) for use in web applications.

+7
source

Bootstrapping is just a piece of code that will be executed for each request.
You can place a function or object when you want more, according to your frame structure structure.

It should not have special functions.

+3
source

Source: https://habr.com/ru/post/1445101/


All Articles