4

I am making my own MVC framework (please do not downvote me because everyone wants to make a framework.) and so.. I want to make a bootstrapping class like I have seen in many frameworks. I am making this because I have decided to move to the next level by started learning a framework from the inside. But I am facing few problems getting through them. But I will separate them in different questions. Now to clarify my question:

What features should a Bootstrapping class have? And Can you give me articles that could help me?

2 Answers 2

7

There should not be a "bootstrap class". It is a straightforward process, which can be contain in a simple script, which would serve as entry point for your application. PHP is not Java, therefore you are not require to contain everything within a class.

Usually bootstrap stage of application would have following responsibilities:

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

The bootstrap stage in you application is where all the wiring between objects should be set up. It would also be the place where you set up such things as loggers, access control and error handling structures.

You could say that front controller is a part or bootstrapping.

P.S.: also, you might find this answer of mine relevant, since it also contains an example of bootstrap file.


List of recommended articles:

The last two links cover two of 3 major MVC-inspired patterns (Model2 MVC and MVP), since classical MVC is actually highly impractical (and actually, almost impossible) to be used for web applications.

Sign up to request clarification or add additional context in comments.

Comments

3

Bootstrapping is just a piece of code that will by executed for each requests.
You can place a function or an object whenever you like more according to your framework dir structure.

It must not have some particular features

5 Comments

so it is more like an autoloader than a big technique, am I getting this correct ?
More and less. Autoloader can be called more than once for each requests... bootstrapping will be executed only once before any controllers code
so lets say It like that the Bootstrapper making requests additional files than the defined. lets say it like this: The user writes the autoloader and the boot strap and the bootstrapper requests additional files needed by the application and makes the autoloader request them. Correct ?
Bootstrap and autoloader are two different thing. Autoloader is called whenever your request an undefined class like this: $var = new MyCustomClass(); You can of course instanciate new object in the bootstrap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.