【问题标题】:Apache Solr Class 'SolrClient' not found fatal errorApache Solr 类“SolrClient”未找到致命错误
【发布时间】:2015-02-25 09:39:50
【问题描述】:

我正处于 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/');

?>

【问题讨论】:

标签: php apache solr configuration classnotfoundexception


【解决方案1】:

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

sudo pecl install solr

如果此操作失败并出现错误,那可能是由于您使用的 php 版本 (7.*)。将此错误报告给forum

然后按照thisgithub仓库中的说明编译构建。

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

这对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-27
    • 2014-08-11
    • 2017-07-27
    • 2012-10-14
    • 1970-01-01
    相关资源
    最近更新 更多