Saturday, February 26, 2011

Zend Framework's Zend_Application and Bootstrapping

I am trying to make sense of all these bootstrapping that happens in the Zend Framework so I finally had a chance to dig in to the source code and this is what I've learned:

Zend_Application is the big moma of the bootstrapping process. If you want to change you config file to an XML from the default INI you need to do it in Zend_Application. As an example, edit the Zend_Application instantiation in public/index.php to make as an XML.

public/index.php
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.XML'
);

Within __construct initialization of Zend_Application, Zend_Config class is called. You need to take a look at /Zend/Application.php->_loadConfig() to understand and from within the class depending upon the extension of your config file (for us its .XML) it will load Zend_Config_Xml or Zend_Config_Ini as default.

Back to the bootstrap process. We go back to Zend_Application as the resources from Zend_Config are initialized.

If you are pretty new to Zend Framework and looked at the default .ini file you might get overwhelmed on where in the world they refer all these resources and extra configurations. I was not able to find it quickly in the official ZF doc but here is the link http://framework.zend.com/manual/1.11/en/zend.application.core-functionality.html

In any case, I will mention the default options here. You can see all these in the source code of  Zend_Application->setOptions(). Again i am talking about the application.ini file that is set through the bootstrap process.

//application.ini
phpsettings
includepaths
autoloadernamespaces
bootstrap

There is also one configuration that you may wonder where it came from:
appnamespace = "Application"

The appnamespace is initialized when the Zend_Application_Bootstrap_BootstrapAbstract->_construct is run. it will proxy to setOptions() method and this will look for any setters within the Bootstrap class namespace and Zend_Aplication_Bootstrap_Bootstrap->setAppNamespace() will be initialized automatically.

You can also set your own options. Mine has the Smarty parameters:


smarty.layout_dir = APPLICATION_PATH "/layouts/scripts"
smarty.views_dir = APPLICATION_PATH "/modules/front/views/scripts"
smarty.dir = APPLICATION_PATH "/../library/My/Smarty"
smarty.template_dir = APPLICATION_PATH "/../tpl/templates"
smarty.compile_dir = APPLICATION_PATH "/../tpl/templates_c"
smarty.config_dir = APPLICATION_PATH "/../tpl/configs"
smarty.cache_dir = APPLICATION_PATH "/../tpl/cache"
smarty.caching = 0
smarty.compile_check = true

Resources:
You can get the available resources at http://framework.zend.com/manual/1.11/en/zend.application.available-resources.html
I wont list the resources because theres a bunch of them. If your unfamiliar with the syntax in config its something like:

resources.db.adapter = PDO_MYSQL
resources.db.params.host = 'localhost'

These resources are just proxying to Zend_Aplication_Resource_Db (notice the _Db at the end of the class) which then ports the Zend_Db::factory().
Heres the adapter reference: http://framework.zend.com/manual/1.11/en/zend.db.adapter.html

You can access all this config options in your bootstrap file via
// Bootstrap.php
$this->getOptions();

You can also access your options and resources in the controllers:


 // inside your controller
$bootstrapClass = $this->getInvokeArg('bootstrap');
$smartyConfig = $bootstrapClass->getOption('smarty');
// Database resource
$dbResource = $bootstrapClass->getResource('db');

Thats about it for now

14 comments:

Anonymous said...

Hello. And Bye. Thank you very much.

Anonymous said...

My brother suggested I might like this web site. He was totally right.
This post actually made my day. You can not imagine
just how much time I had spent for this info!
Thanks!

Feel free to visit my blog post: minion rush cheats

Unknown said...

Sergei , October 22, 1970 Born in Christian Louboutin Bois Dore Moscow State Ozherelye. Perhaps influenced by Cheap LV Handbags their parents worship warrior army, join the army in cheap jordans 1989, and into the elite airborne military service. 1991, by the influence of the Soviet Union, the uggs on sale Russian christian louboutin army general lack of funds, a large number ugg australia of Air Jordan 11 Gamma Blue soldiers seeking veterans, but under extremely difficult conditions still dedicated, praise superiors, and soon was sent to the famous christian louboutin shoes Ryazan Higher ugg Airborne Command School studies. After graduating in 1994, entered the famous Pskov 76th Guards Airborne discount christian louboutin Division, served as discount nike jordans the reconnaissance platoon, reconnaissance ugg soldes deputy company commander, company commander, battalion airborne regiment scouting director and other duties.From 2000 to Cheap Louis Vuitton Handbags 2004, where the forces have repeatedly ordered war with Chechen militants. Because of their opponents in order to form the squad activity and haunted impermanence, the Russians had to ugg boots mobilize elite troops set up large uggs outlet number of small units, "a Discount Louis Vuitton small wholesale jordan shoes play small" Implementation siege. commanding troops in Chechnya, Christian Louboutin Daffodile Ingushetia and other places over the mountains, to track the militants fled. Discount LV Handbags Although the militants were extremely vigilant, but as long as the task has never had outsmarted.August 8, 2008, Georgia suddenly invade South Ossetia (Russian peacekeepers stationed ugg pas cher there), the Russian military to respond quickly, including including the 76th Guards Airborne Division, more than christian louboutin remise 50% 3,000 people were immediately delivered to the pro-Russian Abkhazia, Georgia cheap nike jordan shoes Army contain two infantry brigades, effectively coordinate the cheap christian louboutin direction of the Russian Bags Louis Vuitton troops in South Ossetia.

Unknown said...

kate spade handbags
lebron 12
nike air max
prada shoes
los angeles clippers jerseys
nike shoes
nba jerseys wholesale
nike air max,air max uk,air max 90,nike air max 90,air max shoes
arthur jones jersey,deonte thompson jersey,courtney upshaw jersey,timmy jernigan jersey,jeromy miles jersey,haloti ngata jersey,joe flacco jersey,steve smith sr jersey
dallas cowboys jersey
cartier love bracelet
north face jackets
atlanta falcons jersey
the north face jackets
air max 90
new orleans saints jerseys
uggs on sale
gucci outlet online
green bay packers jerseys
peter konz jersey,paul worrilow jersey,prince shembo jersey
michael kors handbags
49ers jersey
evening dresses outlet
the north face outlet store
lebron shoes
nike sneakers
nike air max
mbt shoes outlet
north face jackets
nike free run
zhuweiming0627

Unknown said...

2015-09-16 zhengjx
Michael Kors Outlet Stores Online
canada goose outlet
Kobe Shoes,Kobe 9,Kobe 8 Discount
Coach Factory Outlet Official Coach Handbags Sale
ray-ban sunglasses
Louis Vuitton Handbags Outlet Online
michael kors bag
Coach Outlet Online Coach Factory Outlet
Louis Vuitton Handbags UK For Sale
Louis Vuitton Handbags Official USA Website
timberland boots
ugg boots
Oakley Sunglasses Official Website Cheap Off
coach factory outlet online
nike trainers
toms outlet
celine handbags
michael kors outlet
Hollister UK Clothing Store
Louis Vuitton Outlet Discount Handbags
Cheap Louis Vuitton Handbags Luggage Bags Sale
cheap jordans
hollister uk
michael kors bags
ugg boots sale
Gucci Outlet Online 80% OFF
ugg australia
michael kors outlet
Mont Blanc Pens For Sale
Michael Kors Outlet Online 70% Off Handbags

Unknown said...

ray ban sunglasses, http://www.raybansunglassesonline.us.com/
nike trainers, http://www.niketrainers.me.uk/
gucci handbags, http://www.guccihandbags-outlet.co.uk/
herve leger, http://www.herveleger.us.com/
timberland boots, http://www.timberlandboots.name/
coach outlet online, http://www.coachoutletonline-store.us.com/
michael kors outlet, http://www.michaelkorsoutletcanada.in.net/
juicy couture outlet, http://www.juicycoutureoutlet.net/
calvin klein underwear, http://www.calvinklein.in.net/
ray ban sunglasses, http://www.raybansunglass.us.com/
prada outlet, http://www.pradaoutlet.us/
lululemon outlet, http://www.lululemonoutletstore.in.net/
tory burch shoes, http://www.toryburchshoesoutlet.com/
michael kors outlet, http://www.michaelkorsoutlet.org.uk/
replica watches, http://www.replicawatchesforsale.us.com/
pandora jewelry, http://www.pandorajewelryoutlet.us.com/
nfl jerseys wholesale, http://www.nfljerseys-wholesale.us.com/
michael kors outlet, http://www.michaelkorsoutletonlinstore.us.com/
oakley outlet, http://www.oakleyoutlet.in.net/
oakley sunglasses, http://www.oakleysunglasses-outlet.us.com/
michael kors bags, http://www.michaelkorsbags.uk/
ray ban sunglasses, http://www.ray-bansunglasses.eu.com/
oakley sunglasses, http://www.oakley.in.net/
air max 2015, http://www.airmax2015.in.net/
the north face uk, http://www.thenorthfaces.org.uk/
swarovski outlet, http://www.swarovski-outlet.co.uk/
pandora jewelry, http://www.pandora.eu.com/
chanel handbags, http://www.chanelhandbags-outlet.co.uk/
1002maoqiuyun

chenlina said...

chenlina20151127
replica watches
ugg sale
lebron shoes
coach outlet store online
uggs boots
canada goose jackets
ugg outlet
louis vuitton handbags
gucci shoes
ray ban outlet store
mont blanc legend
michael kors handbags
ray ban sunglasses
louis vuitton handbags
cheap uggs
hollister co
kobe 9
adidas superstars
hollister
north face jackets
tory burch sale
ugg australia
louis vuitton handbags
timberland outlet
michael kors outlet online
canada goose jackets
louis vuitton outlet
hollister co,hollister jeans,hollister.com,hollister ca
coach outlet store online
michael kors outlet
louis vuitton purses
michael kors outlet
uggs on sale
adidas originals
louis vuitton
louis vuitton handbags
michael kors outlet online
giuseppe zanotti
nike roshe run women
ugg boots on sale
as

chenlina said...

chenlina20160127
michael kors outlet
michael kors outlet online
polo ralph lauren
oakkey sunglasses
swarovski outlet
louis vuitton outlet
jordan retro
louis vuitton handbags
abercrombie outlet
oakley sunglasses
jordan retro 11
toms outlet
coach outlet online
coach outlet
burberry scarf
coach factory outlet
coach factory outlet
ed hardy clothing
cheap oakley sunglasses
lebron shoes
louis vuitton handbags
adidas superstars
louis vuitton outlet
ray ban sunglasses outlet
cheap jordans
coach factory outlet
michael kors outlet
ugg sale
beats by dr dre
canada goose outlet
louis vuitton
christian louboutin shoes
oakley outlet
ray ban sunglasses
ugg outlett
oakley sunglasses
abercrombie and fitch
ray ban sunglasses
soccer shoes
true religion jeans outlet
as

Unknown said...

nike huarache
north face
michael kors outlet
lebron james shoes
ralph lauren outlet
michael kors handbags sale
new balance shoes
supra shoes sale
michael kors handbags
michael kors handbags

caiyan said...

tommy hilfiger outlet
hollister clothing store
michael kors handbags outlet
ralph lauren outlet
jerseys cheap
fitflops clearance
adidas sneakers
christian louboutin outlet
polo ralph lauren
birkenstock shoes
0413shizhong

Unknown said...

adidas outlet
nike air max 90
gucci outlet
ugg boots
timberland boots
nike store
pandora jewelry
yeezy boost 350
fitflops shoes
polo outlet
mt0718

koko said...

ralph lauren outlet
canada goose jackets
moncler outlet
nike factory store
pandora outlet
moncler jackets
fitflop shoes
nike outlet store
san diego chargers jerseys
pandora charms outlet

zzyytt said...

adidas yeezy boost
nike huarache
balenciaga
yeezy 500 blush
yeezy shoes
jordan 11
hermes belts
jordan shoes
jordan shoes
nmd r1

5689 said...

zzzzz2018.11.6
north face
kate spade handbags
canada goose outlet
tory burch outlet
mbt shoes
red bottom shoes
ecco shoes
manolo blahnik
canada goose jackets
hogan shoes