Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2010
    Location
    Cardiff, UK
    Posts
    24
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •