0

Ive been battling this all day. Is there a way to install PHPLinq so it works with the Zend library autoloader?

Alternatively, if I just have to use include, is there a way that I can ensure the pathing for the other includes in the PHPLinq library.

Obviously Im new to PHP and just getting this library to get recognized in Zend has been a day killer. Never Thought id pine for the days of working in .Net :/

Thanks in advance!

MFD3000
  • 854
  • 1
  • 11
  • 26
  • Can you provide an link to the PHPLinq library you're using? – Jeremy Kendall Jan 11 '12 at 20:50
  • http://phplinq.codeplex.com/ , http://plinq.codeplex.com/ and http://linqforphp.codeplex.com/ are the three I'm aware of... I'm guessing OP is using the first – Mark Baker Jan 11 '12 at 21:47
  • You can write an autoloader class for the PHPLinq library that you can push onto the `Zend_Loader_Autoloader` stack. See: http://stackoverflow.com/a/8820536/131824 – David Weinraub Jan 12 '12 at 02:06

1 Answers1

1

AutoLoading in Zend can be used with any library that supports the naming convention of Zend. That is, put classes in a folder and then all classes underneath it follow the:

FOLDER_SUBFOLDER_FILENAME

pattern. So you need to have for example:

MyLib > ClassName.php

And the class must be called

MyLib_ClassName

If these requirement are ok, then just doing:

// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/'));

// Ensure /libraries is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/libraries'),
    get_include_path(),
)));

//Include the Zend Autloader
include('Zend/Loader/Autoloader.php');

//Create the autoloader and register the Activis_ namespace
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('YourFirstLevelFolder_');

Then when you have registered your namespace and made sure your classes work with the naming convention, using NEW should load ANYTHING you configured.

Good luck

Mathieu Dumoulin
  • 12,126
  • 7
  • 43
  • 71