We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 964
    • 11 Posts
    Hi,

    I didn’t find a post on how to use Zend Framework libraries from within MODx (Evo), so thought I would just post a quick howto here:

    1. DL the Zend Framework libraries from http://framework.zend.com/download/latest (you just need the Minimal install)

    2. Unzip them to a path e.g. /var/www/libraries/Zend (you just need the contents of the library folder from the zip)

    3. Create a new snippet called zend.inc.php in a folder called zend with the following contents:

    <?php
    /**
     * This is a Zend Framework loader for MODx Evolution
     * Author: Alex Dean @alexatkeplar
     */
    
    define('LIBRARY_PATH', '/var/www/libraries/'); // Update as appropriate
    
    // First make sure the Zend library is in the include path:
    ini_set('include_path',
    ini_get('include_path') . PATH_SEPARATOR . LIBRARY_PATH);
    
    // Then require the Autoloader class:
    require_once 'Zend/Loader/Autoloader.php';
    
    // Instantiate the loader
    $loader = Zend_Loader_Autoloader::getInstance();
    


    4. Now in a MODx snippet you can use Zend like so:

    <?php
    require_once($modx->config['base_path'] . 'assets/snippets/zend/zend.inc.php');
    
    $userLocale = new Zend_Locale(Zend_Locale::BROWSER); // Or whatever...
    $userLanguage = $userLocale->getLanguage();
    


    Hope this is helpful! Let me know if it is and I’ll post another howto on integrating MaxMind geo-IP with MODx...
      • 26931
      • 2,314 Posts
      alexatkeplar, thanks for sharing!
        • 4310
        • 2,310 Posts
        Interested to see the MaxMind geo-IP with MODx integration.
        Thanks for the howto.
          • 964
          • 11 Posts
          Quote from: bunk58 at Jun 23, 2010, 05:09 AM

          Interested to see the MaxMind geo-IP with MODx integration.

          Please find it here: http://modxcms.com/forums/index.php/topic,50853.0.html
            • 37099
            • 338 Posts
            What sort of things do you use Zend for in ModX? I’ve used it for HTML emails so far, but that’s all.

            Mike
              • 473
              • 70 Posts
              thanks for lexatkeplar, I propose to be used as a standard library folder so that third-party libraries such as Zend Framework, phpThumb, MaxMind, eZ Components and others can be used in other snippets, plug-in, or module without duplication. Probably better in the folder assets/libraries/
                • 36756
                • 7 Posts
                I use the LiveDocx Service in the Zend Framework for creating docx and .pdf documents + data from 3rd party database tables. Works like a charm.