Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-26-2012, 12:10 PM   PM User | #1
john_w3
New Coder

 
Join Date: Jan 2010
Location: Cardiff, UK
Posts: 21
Thanks: 2
Thanked 0 Times in 0 Posts
john_w3 is an unknown quantity at this point
Zend Bootstrap.php usage

Hi,

I have some code in my Zend index.php that I would like to move to my Bootstrap.php
public/index.php
application/Bootstrap.php

For example, these two lines:
Code:
$ini_constants = new Zend_Config_Ini(APPLICATION_PATH."/configs/constants.ini", 
APPLICATION_ENV);
Zend_Registry::set('ini_constants',  $ini_constants);
This is what Bootstrap.php looks like now:
Code:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	public function WHAT_SHOULD_I_CALL_THIS_FUNCTION()
	{
		// Should I put my code here?
	}
}
My questions ....
1. What should I use instead of: WHAT_SHOULD_I_CALL_THIS_FUNCTION:
2. Is inside that function the correct place to put my code from index.php?
3. How do I get that function to run? I have the below at the bottom of my index.php

$application->bootstrap()->run();


I am using Zend version 1.11.11

Thank you.

Last edited by john_w3; 11-26-2012 at 12:11 PM.. Reason: Added instant e-mail notification.
john_w3 is offline   Reply With Quote
Old 11-26-2012, 05:12 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
I don't know anything about the zend framework. But if you are calling this: $application->bootstrap()->run(); and bootstrap is a method that returns that Bootstrap object type, then you want to name your function run(). Call parent::run() as the first line within it, then continue with putting any data you need. I'm assuming that the run method is inherited from the Zend_Application_Bootstrap_Bootstrap class, but you can override it in your child and call the parent when you want. If the data you want to move is located before the $application's boostrap run call, then you probably want to set that prior to parent call to the run.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
bootstrap, php, zend

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:15 PM.


Advertisement
Log in to turn off these ads.