Laravel 5 如何与Laravel一起使用日光浴室?
我已经按照要求在Laravel 5 如何与Laravel一起使用日光浴室?,laravel-5,solarium,Laravel 5,Solarium,我已经按照要求在composer.json上安装了Solarium,安装了composer,一切都很顺利 但是,当我尝试创建客户端姿态时,会出现一个错误: 找不到类别“Solarium\Client” 我使用的代码如下所示: public function __construct() { $config = array( 'endpoint' => array( 'localhost' => array(
composer.json
上安装了Solarium,安装了composer
,一切都很顺利
但是,当我尝试创建客户端姿态时,会出现一个错误:
找不到类别“Solarium\Client”
我使用的代码如下所示:
public function __construct()
{
$config = array(
'endpoint' => array(
'localhost' => array(
'host' => '127.0.0.1',
'port' => 8983,
'path' => '/solr/my_solr_instance',
)
)
);
$this->client = new \Solarium\Client($config);
}
关于如何解决这个问题有什么想法吗?在拉威尔安装日光浴室之后 在config中创建一个文件solr.php
return [
'endpoint' => [
'Collection' => [
'host' => '192.168.0.1',
'port' => '8983',
'path' => '/solr',
'core' => 'collection1'
],
]
];
在控制器构造中,启动客户端对象
// create a client instance
$this->client = new \Solarium\Client();
$this->endpoint = $this->client->createEndpoint(Config::get('solr.endpoint.Collection'));
搜索功能
$query = $this->client->createSelect();
$query->setQuery("*:*");
$resultset = $this->client->select($query, $this->endpoint);
我有一个新的方法从控制器启动客户端。 我发现这个解决方案如下:发布完整的代码是不好的
我已经试过了,也测试过了,所以会对您有所帮助。您是否在服务提供商(config/app.php)中包含了包名?'Fbf\LaravelSolarium\LaravelSolariumServiceProvider'看起来该软件包与laravel5不兼容,我使用的是常规的日光浴软件包,而不是laravel软件包。最后,经过一天的努力,我写了一篇帖子-