ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

EE2 extension include_path best practice

May 02, 2011 1:20pm

Subscribe [1]
  • #1 / May 02, 2011 1:20pm

    Fritzinger

    35 posts

    Hope someone can help a php noob out. I’ve created an extension which will use Zend_Search_Lucene to provide ranked search results. In

    system/expressionengine/third_party/ranked_search/ext.ranked_search.php

    I use the line:

    require_once('Zend/Search/Lucene.php');

    The Zend folder is in the same directory as ext.ranked_search.php and Lucene.php is found with no problems, but it references other files as follows:

    require_once 'Zend/Search/Lucene/Document/Docx.php';
    require_once 'Zend/Search/Lucene/Document/Pptx.php';
    //etc

    These files are not found unless I add

    set_include_path(get_include_path() . PATH_SEPARATOR . 'expressionengine/third_party/ranked_search/');

    This seems a bit messy because now the include_path() is changed for all code outside of my extension. Is there a better way of doing this, like setting the include path for my module only?

    Also I’d prefer to bundle the Zend code with my extension so that it can be installed in one step, rather than requiring the user to copy it into some libraries folder as a separate step.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases