没有发现Apache Solr Class'SolrClient'致命错误

时间:2015-02-25 09:39:51

标签: php apache solr configuration classnotfoundexception

我正处于WAMP服务器上的Apache Solr配置阶段。 当我在WAMP服务器上运行此代码时,它显示PHP致命错误,

致命错误:第54行的C:\ wamp \ www \ Search Enginge \ home.php中找不到“SolrClient”类

Home.php

<?php
include "bootstrap.php";

$options = array
(
        'hostname' => SOLR_SERVER_HOSTNAME,
        'login'    => SOLR_SERVER_USERNAME,
        'password' => SOLR_SERVER_PASSWORD,
        'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

$query = new SolrQuery();

$query->setQuery("*.*");

$query->addField('id')->addField('author')->addField('content_type')->addField('user')->addField('file_type');

$query->setFacet(true);

$query->addFacetField('content_type')->addFacetField('file_type');

$query_response = $client->query($query);

$response = $query_response->getResponse();

$array=(array)$response['facet_counts']['facet_fields']['file_type'];

?>

bootstrap.php中

<?php

/* Domain name of the Solr server */
define('SOLR_SERVER_HOSTNAME', 'localhost');

/* Whether or not to run in secure mode */
define('SOLR_SECURE', true);

/* HTTP Port to connection */
define('SOLR_SERVER_PORT', ((SOLR_SECURE) ? 8990 : 8990));

/* HTTP Basic Authentication Username */
define('SOLR_SERVER_USERNAME', 'admin');

/* HTTP Basic Authentication pasword */
define('SOLR_SERVER_PASSWORD', '');

/* HTTP connection timeout */
/* This is maximum time in seconds allowed for the http data transfer operation. Default value is 30 seconds */
define('SOLR_SERVER_TIMEOUT', 10);

/* File name to a PEM-formatted private key + private certificate (concatenated in that order) */
define('SOLR_SSL_CERT', 'certs/combo.pem');

/* File name to a PEM-formatted private certificate only */
define('SOLR_SSL_CERT_ONLY', 'certs/solr.crt');

/* File name to a PEM-formatted private key */
define('SOLR_SSL_KEY', 'certs/solr.key');

/* Password for PEM-formatted private key file */
define('SOLR_SSL_KEYPASSWORD', 'StrongAndSecurePassword');

/* Name of file holding one or more CA certificates to verify peer with*/
define('SOLR_SSL_CAINFO', 'certs/cacert.crt');

/* Name of directory holding multiple CA certificates to verify peer with */
define('SOLR_SSL_CAPATH', 'certs/');

?>

1 个答案:

答案 0 :(得分:0)

只需使用pecl安装solr-php客户端;

sudo pecl install solr

如果失败并显示错误,则可能是由于您使用的是php版本(7. *)。向此forum报告此错误。

然后根据this github存储库中的说明进行编译和构建。

(如果您使用的是较新版本的php(7. *),请忽略库“ php5-curl”)

这对我有用。