0

I'm using Elastica search engine for my Symfony project.

Now, I'm getting the below error :

The autoloader expected class "Elastica_Query_Bool" to be defined in file "/blablabla/vendor/ruflin/elastica/lib/Elastica/Query/Bool.php". The file was found but the class was not in it, the class name or namespace probably has a typo.

If I change new \Elastica_Query_Bool() for new \Elastica\Query\Bool() in my php file, it works fine.

But I can't understand why I'm getting an error now. Any idea ?

1 Answer 1

1

Because when you new Elastica_Query_Bool it's looking for a class actually called Elastica_Query_Bool. And of course the actual class is called Bool.

try:

use Elastica\Query\Bool; // At the top of your file following the namespace line.
...
$bool = new Bool();

Might want to review namespaces in the php manual.

Sign up to request clarification or add additional context in comments.

4 Comments

Yeah sure, it's looking for this class and it does not exist but it worked before. More, all the examples I can find on Elastica suggest to use new Elastica_Query_Bool(). So maybe something change in Elastica bundle or in a newest version of Symfony ?
Check the Bool.php file. Does it have a namespace deceleration? If it does then it means it has been upgraded from a pre=namespace version. You must be looking at old examples.
This article might help: richardmiller.co.uk/2011/11/11/…
I've just had a look to the history of the file Bool.php in https://github.com/ruflin/Elastica/ repository, and this commit https://github.com/ruflin/Elastica/commit/94b4b8ac854fafefaad5b51831094d34f9b4ebfd introduced the use of namespace. So, no more "_" (like the other bundles) and I have my answer :) By the way, your answer is correct (even if it does not really fit to my question).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.