Symfony 与Solr一起使用日光浴室
我正在尝试将Solarium(NelmioSolariumBundle)与Solr一起使用,我收到以下错误消息:Symfony 与Solr一起使用日光浴室,symfony,solr,solarium,nelmiosolariumbundle,Symfony,Solr,Solarium,Nelmiosolariumbundle,我正在尝试将Solarium(NelmioSolariumBundle)与Solr一起使用,我收到以下错误消息: Service "solarium.client" not found: even though it exists in the app's container, the container inside "App\Controller\solariumController" is a smaller service locator that only knows about th
Service "solarium.client" not found: even though it exists in the app's container, the container
inside "App\Controller\solariumController" is a smaller service locator that only knows about the
"doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router",
"security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "session"
and "twig" services. Try using dependency injection instead.
这是我的控制器
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class solariumController extends AbstractController
{
/**
* @Route ("/solariums", name="solariums")
*/
public function solariumSearch(){
$client = $this->get('solarium.client');
$select = $client->createSelect();
$select->setQuery('brandon');
$results = $client->select($select);
return $this->render('pages/solarium.html.twig',[
'$results'
]);
}
}
在构造函数中插入客户端:
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class solariumController extends AbstractController
{
/** @var \Solarium\Client */
private $client;
public function __construct(\Solarium\Client $client) {
$this->client = $client;
}
/**
* @Route ("/solariums", name="solariums")
*/
public function solariumSearch() {
$select = $this->client->createSelect();
$select->setQuery('brandon');
$results = $this->client->select($select);
return $this->render('pages/solarium.html.twig',[
'$results'
]);
}
}
有效,谢谢!现在我只需要找到如何制作搜索表单和上传表单!它是有效的,但我收到了一个弃用警告。这里描述的是:有什么想法如何解决?