Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Basic Zend package
  • If you like to use Zend classes inside your app: Make new package folder zend: packages/zend/ Inside make new folder pack and file bootstrap.php: packages/zend/pack/
    packages/zend/bootstrap.php Inside the pack folder you add the downloaded files from Zend Full/Minimal Inside the bootstrap.php file:
    <?php
    
    /**
     * Go to packages/zend/pack and run these two lines to comment out ALL the require_once lines
     * find ./library/ -type f -name '*.php' -print0 | xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'
     * find ./extras/library/ -type f -name '*.php' -print0 | xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'
     *
     * NOTE! This is not needed but recommended because there is no need to
     * use require_once in the class files anymore. This saves server loading 
     * time up to 25% when using Zend classes.
     */
    
    $paths = array(
     __DIR__.DS.'pack'.DS.'library',
     __DIR__.DS.'pack'.DS.'extras'.DS.'library',
     get_include_path()
    );
    
    set_include_path(implode(PATH_SEPARATOR, $paths));
    
    // Startup the Zend Loader and Autoloader (Zend < 2.0)
    
    require __DIR__.DS.'pack'.DS.'library'.DS.'Zend'.DS.'Loader.php';
    require __DIR__.DS.'pack'.DS.'library'.DS.'Zend'.DS.'Loader'.DS.'Autoloader.php';
    
    Zend_Loader_Autoloader::getInstance();
    
    /* End of file bootstrap.php */
    

    Do not forget to add zend to packages in your application config. NOTE: This is only for Zend < 2.0 Hopefully 2.0 has autoloading like Fuel PHP.
  • @snrp: thanks! That was it.
  • Hi ! I am trying to mess around integrating an ACL library. I saw your post on thought I'd give Zend ACL a try but run into problems.
    Most likely related to my understanding - or lack thereof - of namespaces etc. I integrated the Zend packages as you described and that worked like a charm. This is how it starts in a sample controller:
    namespace Myauth;
    
    class Controller_Myauth extends \Controller_User &#123;
    
        public function before()
        &#123;
            parent::before();
        }
    
        public function action_index()
        &#123;
            $acl = new \Zend_Acl();
            $acl::addRole(new \Zend_Acl_Role('guest'));
    
        .....
        }
    }
    

    but there the trouble also begins....
    fuel yells at me with
    ErrorException [ Notice ]: Undefined property: Myauth\Controller_Myauth::$_roleRegistry
    
    and
    ErrorException [ Error ]: Call to undefined method Myauth\Controller_Myauth::_getRoleRegistry() (
    

    both in the fuel/packages/zend/pack/library/Zend/Acl.php file. That does resolve in a way if I replace
    $this->_getRoleRegistry()
    with
    self::_getRoleRegistry()

    but I don't really want to do that.... or do I have to? Could you (or anybody) shed any light on what to do about this? Thanks for your help! mic
  • ErrorException [ Notice ]: Undefined property: Myauth\Controller_Myauth::$_roleRegistry

    When getting errors such as this (where a property of your class is 'looked for' in the controller) it is usually bk you do a static function call, then inside the static function there is a not so static $this->something. And sure enough there it is:
    $acl::addRole(new \Zend_Acl_Role('guest'));

    I have played a bit with ZF (mainly this guy's excelent video tutorial: http://www.youtube.com/user/integral30). That is supposed to be:
    $acl->addRole(new \Zend_Acl_Role('guest'));

    ZF doesnt use static calls too much.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

  • mic January 2011
  • snrp January 2011