Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Integrating Zend Framework lib / Autoload

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1704 Views
  • rob.s
    Avatar
    Community Member
    78 Posts

    Integrating Zend Framework lib / Autoload Link to this post

    Hi,

    anyone got an idea of integrating Zend Framework Classes/Components with the Zend Autoload features ?
    In my App i want to use some zf classes inside an SS class.
    Don't get it working.....

    Kind regards,
    Robert

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Integrating Zend Framework lib / Autoload Link to this post

    Sapphire will autoload classes for you. Just make sure the Zend classes are sitting somewhere that Sapphire can add them to the manifest. Note that 2.4 actually uses some Zend classes (Caching and Date stuff in particular I think), so you can have a look at those for examples.

  • rob.s
    Avatar
    Community Member
    78 Posts

    Re: Integrating Zend Framework lib / Autoload Link to this post

    Hmmm, i do not think it's a good approach to add thousands of classes to the manifest.

    For now i will do it this way:

    sapphire/core/Core.php

    function __autoload($className) {
       global $_CLASS_MANIFEST;
       if(isset($_CLASS_MANIFEST[$className])) {
          include_once($_CLASS_MANIFEST[$className]);
       } elseif ( substr ($className, 0, 4) == "Zend" ) {
          require(str_replace('_', '/', $className) . '.php');
       }
       
    }

    inside an own Method of a controller:

    $user = 'XXXXX@googlemail.com';
    $pass = 'YYYYYYYYY';
    $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
    $client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);
    $gdataCal = new Zend_Gdata_Calendar($client);
    $this->gdataCal = $gdataCal;

    Assuming that the Zend Framework lib is in the include_path.

    Works fine.

    I will try to do solve it a less ugly way ......

    Robert

    1704 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.