Prev | Current Page 266 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"


Licensed to Menshu You
Zend Framework in Action (Ch01) Manning Publications Co. 2
10.1.1 Designing for different environments
One of the goals for any kind of application is the ability to move between different environments and work
with minimal reconfiguration. Other than requiring PHP 5.1.4 or greater the Zend Framework itself has few
specific requirements so it is largely a matter of careful design as to how much we need to vary our own
application.
Most of the differences between one application and another occur during initialisation where the
configuration settings are read in. In a Zend Framework application this most commonly occurs in the
???bootstrap??? file. We are actually going to separate the bootstrapping into its own class to which we can pass
the deployment environment as a parameter from the index.php file in the web root as shown in listing 10.1.
Listing 10.1 The contents of our index.php file which will live in the web root.
set_include_path(get_include_path() . PATH_SEPARATOR
. '/path/to/zf-working-copy/trunk/incubator/library/' ); A
set_include_path(get_include_path() . PATH_SEPARATOR
. '/path/to/zf-working-copy/trunk/library/' ); A
include '../application/bootstrap.php'; B
$bootstrap = new Bootstrap('nick-dev');
$bootstrap->run(); C
A Set paths specific to the environment under which the application is running
B Include our bootstrap file and instantiate it with the configuration section to use
C Run the application
You'll notice that an additional benefit of this is that it allows us to set any environment specific paths, such as
in this case to a local working copy of the latest Zend Framework core components as well as the ???incubator"
components.


Pages:
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
House Extension London zakłady bukmacherskie Potopek szkolenia dla przedsiębiorców nocleg lodz