如何在Symfony2中实现Sphinx搜索引擎

How to implement Sphinx search engine in Symfony2

我正在尝试在我的 Symfony2 项目中实现 Sphinx。我读到我必须包含 sphinxapi.php 文件,但我确实知道如何在 Symfony2 中使用 include() 函数。

请勿使用 include() 来实现此目的。 创建服务:

sphinxService:
    class: 'path\to\sphinxapi.php'

然后在您的控制器中,通过容器调用它:

$sphinxApi = $this->container->get('sphinxService');