Page 1 of 1
bootstrapping
Posted: Sat May 17, 2008 7:36 am
by koen.h
How much does the bootstrap handle, ie what are its responsabilities?
It seems like it is being used for a whole range of tasks, from settings to choosing wich parts (classes) will play in the application.
Re: bootstrapping
Posted: Sat May 17, 2008 12:24 pm
by Eran
Re: bootstrapping
Posted: Sat May 17, 2008 5:21 pm
by koen.h
Thanks but I've already read that and it doesn't tell me much besides a lot of stuff about htaccess.
Re: bootstrapping
Posted: Sat May 17, 2008 5:49 pm
by Eran
What is Bootstrapping?
Many PHP applications funnel server requests into a single (or few) PHP source file that sets up the environment and configuration for the application, manages sessions and caching, and invokes the dispatcher for their MVC framework. They can do more, but their main job is to take care of the consistent needs of every page of a web application.
That's exactly what a bootstrap file does. You funnel requests to it using the url rewrite engine of your server, the script is responsible for loading up all the required resource by your application and forwarding the request forward to the rest of your application.
Re: bootstrapping
Posted: Sat May 17, 2008 6:02 pm
by koen.h
As far as I know that sound more the job of the front controller.
I would point to the "Example Zend Framework Blog Application Tutorial" at blog.astrumfutura.com but it's down for the moment. The bootstrap class there has nothing to see with htaccess.
Re: bootstrapping
Posted: Sat May 17, 2008 6:10 pm
by Christopher
koen.h wrote:Thanks but I've already read that and it doesn't tell me much besides a lot of stuff about htaccess.
I skims over it at the very end. The bootstrap or index.php file usually does a number of things in modern, controller-based frameworks. Here are some of them in semi-order of execution:
- Set include paths
- Load configuration data
- Create a Registry and any objects to be registered with it
- Create and configure any Access Control code used framework-wide
- Initialize the HTTP Request and routing
- Create, configure and run the Front Controller
- Send the Response to the browser (this may be done within the controllers too)
Re: bootstrapping
Posted: Wed May 21, 2008 2:59 am
by Maugrim_The_Reaper
By the way, my blog is now back up and running orders of magnitude faster

.
In the ZF, the bootstrap is not actually defined as such. But good practice would dictate that it be a class which is responsible for setting up resources required by the application, injecting those resources into the application via a Registry or Setters, and managing initial environmental and configuration settings.
The class part is important. I used a class with lots of static methods in the blog app series mainly since I found this fits best. The bootstrap class even with heavy refactoring would have almost nothing for private methods, and making them static allows for reuse by an external library like PHPUnit or PHPSpec.