Welcome Guest, Not a member yet? Register   Sign In
PECL Extension Solr PHP extension with Codeigniter 4
#1
Star 
(This post was last modified: 09-20-2020, 02:28 AM by myo.)

Hi,

I tried to use Solr PHP extension. I downloaded [font=verdana, arial, helvetica, sans-serif]7.4 Thread Safe (TS) x64 and placed php_solr.dll file in ext folder, added in php.ini  & restarted server. [/font]
[font=verdana, arial, helvetica, sans-serif]Then I checked php info & found that solr & libxml extension is enabled.[/font]

Quote:solr Solr Support  enabled
Version 2.5.1
Last Build Date Sep 9 2020
Last Build Time 17:44:35

[font=Monaco, Consolas, Courier, monospace][font=sans-serif]libxml
libXML Compiled Version 2.9.10[/font]
[/font]


[font=verdana, arial, helvetica, sans-serif]I also checked & found libcurl is also installed[/font]

Code:
C:\Users\myo>curl -V
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: [unreleased]
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL


[font=verdana, arial, helvetica, sans-serif]Then I added constants in config/constants and added following (taken from example 2) in Home controller:[/font]


PHP Code:
    public function index() {

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

        $client = new SolrClient($options);

        $doc = new SolrInputDocument();

        $doc->addField('id'334455);
        $doc->addField('name''Software');

        $updateResponse $client->addDocument($doc);

        print_r($updateResponse->getResponse());
    

[font=verdana, arial, helvetica, sans-serif]But when I execute I get error:[/font]


PHP Code:
Error Class 'App\Controllers\SolrClient' not found 


[font=verdana, arial, helvetica, sans-serif]Kindly advise how to resolve this issue?[/font]

[font=verdana, arial, helvetica, sans-serif]Regards[/font]
Reply
#2

put a backward slash in front.

\SolrClient
\SolrInputDocument
Reply




Theme © iAndrew 2016 - Forum software by © MyBB