Created
February 21, 2011 06:50
-
-
Save basdenooijer/836745 to your computer and use it in GitHub Desktop.
Include / autoload Solarium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo Solarium_Version::VERSION; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = '/path/to/solarium/library/Solarium'; | |
// the path is added to the existing include path | |
set_include_path(get_include_path() . PATH_SEPARATOR . $path); | |
// autoloader that determines filename based on classname | |
function myAutoload($class) | |
{ | |
$filename = str_replace('_', '/', $class) . '.php'; | |
require_once($filename); | |
} | |
spl_autoload_register('myAutoload'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// this uses the supplied autoloader, the easiest way to 'load' Solarium | |
require('/path/to/solarium/library/Solarium/Autoloader.php'); | |
Solarium_Autoloader::register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap | |
{ | |
public function _initAutoloader() | |
{ | |
// Create an resource autoloader component | |
$autoloader = new Zend_Loader_Autoloader_Resource(array( | |
'basePath' => APPLICATION_PATH, | |
'namespace' => '' | |
)); | |
// Add some resources types | |
$autoloader->addResourceTypes(array( | |
'solarium' => array( | |
'path' => '../library/Solarium', | |
'namespace' => 'Solarium' | |
), | |
)); | |
// Return to bootstrap resource registry | |
return $autoloader; | |
} | |
} |
Thanks for the tip, I fixed the path. I hope you like the library, if you run into any issues please let me know.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In SolariumAutoloader.php (and according to the current structure on github), I guess it should be
require('/path/to/solarium/library/Solarium/Autoloader.php');
(This is really nitpicking but hell... just about to check out this promising library and pointing this out is the least I can do to say thanks, right?)