Skip to content

Instantly share code, notes, and snippets.

@basdenooijer
Created February 21, 2011 06:50
Show Gist options
  • Save basdenooijer/836745 to your computer and use it in GitHub Desktop.
Save basdenooijer/836745 to your computer and use it in GitHub Desktop.
Include / autoload Solarium
<?php
echo Solarium_Version::VERSION;
<?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');
<?php
// this uses the supplied autoloader, the easiest way to 'load' Solarium
require('/path/to/solarium/library/Solarium/Autoloader.php');
Solarium_Autoloader::register();
<?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;
}
}
@aleksblendwerk
Copy link

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?)

@basdenooijer
Copy link
Author

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