My main problem is, that i dont have access to Solarium (a third party libary) in my symfony2-project and I do not understand why. I have a symfony2 application and want to write my own Solr connector. Therefore I want to use Solarium. (IMPORTANT: I dont want to use other bundles for this)
First I installed it via composer
"require": {
//...
"solarium/solarium": "3.3.0.x-dev"
}
Then i called:
php composer.phar install
php composer.phar update
Second i created a new directory for my connector in my bundle:
/src/COMPANY/ThatIsMyBundle/SolrSearch/
In this directory is my class SolrConnector.php
namespace COMPANY\ThatIsMyBundle\SolrSearch;
use Solarium\Client;
//use Solarium\Core\Client;
class SolrConnector {
private $solr_client;
function __construct($settings)
{
$solr_config = array(
'endpoint' => array(
'protokolldb' => array(
'host' => $settings['solrHost'],
'port' => $settings['solrPort'],
'path' => $settings['path'],
'core' => $settings['core'],
'timeout' => $settings['timeout']
)
)
);
$this->solr_client = new Client($solr_config);
}
/**
* Check if Solr is on.
*/
function executePing() {
$ping = $this->solr_client->createPing();
try {
$this->solr_client->ping($ping);
echo "Solr is fine.
";
} catch (Exception $e) {
echo "Solr is unaccessible. Look up whats wrong with Solr and restart this script.
".$e->getMessage();
}
}
}
I got this error message from symfony:
Attempted to load class "Client" from namespace "Solarium" in "(my specific path to the project)/SolrSearch/SolrConnector.php line 32." Do you need to "use" it from another namespace?
What i have to do to use Solarium in my Symfony2 Bundle? I think it is a namespace/use/require problem. I googled it for hours... with no solution.
Things i tried:
adding
require('../vendor/autoload.php);
same error.