0

我正在为我的 Symfony 项目使用 Elastica 搜索引擎。

现在,我收到以下错误:

自动加载器预期类“Elastica_Query_Bool”将在文件“/blablabla/vendor/ruflin/elastica/lib/Elastica/Query/Bool.php”中定义。找到文件但类不在其中,类名或命名空间可能有错字。

如果我在我的 php 文件中更改,它工作正常new \Elastica_Query_Bool()new \Elastica\Query\Bool()

但我不明白为什么我现在收到错误。任何想法 ?

4

1 回答 1

1

因为当您新建 Elastica_Query_Bool 时,它正在寻找一个实际上称为 Elastica_Query_Bool 的类。当然,实际的类称为 Bool。

尝试:

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

可能想要查看 php 手册中的命名空间。

于 2013-08-17T23:08:28.730 回答