Silex + FOQElasticaBundle

问题描述 投票:0回答:1

我的目标是将FOQElasticBundle与我的Silex网站链接。问题是FOQElasticBundle的documentationn声明我只需要在config.yml文件中放入一些基本内容即可。

参见:https://github.com/Exercise/FOQElasticaBundle#declare-a-client

到目前为止,我在任何地方都找不到config.yml文件,我不知道是否必须创建它,以及是否可以将其放置在哪里。我使用Silex而不是Symfony本身在网站上做出了错误的选择吗?还是可以加载FOQElasticBundle?

symfony elasticsearch silex
1个回答
1
投票

您不能直接在Silex中使用Symfony捆绑包。Silex通过服务提供商集成了第三方库,其作用类似于第三方库的适配器。

如果您想使用捆绑包,我建议您最好使用Symfony。

否则,您可以尝试自己为Elastica库write a Service Provider或直接将其集成,如下所示:https://github.com/4devs/demo-silex/blob/master/web/index.php

$app['elastica.host'] = "localhost";
$app['elastica.port'] = 9200;

$app['elastica'] = function ($app) {
    return new \Elastica\Client(array(
        'host' => $app['elastica.host'],
        'port' => $app['elastica.port']
    ));
};

很遗憾,这里没有列出Elastica服务提供商:https://github.com/silexphp/Silex/wiki/Third-Party-ServiceProviders

© www.soinside.com 2019 - 2024. All rights reserved.