Fatal error: Class 'SolrClient' not found - php

I followed this tutorial to run solr using php. However I came across the above error. I looked into the SolrClient Class, but have no idea how to use it.
Is there a step by step guide for this?

Please run the following commands
sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev
sudo apt-get install libpcre3-dev
sudo pecl install -n solr
Please add extension in php.ini file
sudo echo "extension=solr.so" >> /etc/php5/apache2/php.ini
Please create solr.ini file in /etc/php5/apache2/conf.d/ and add extension=solr.so in that file.
or run this command in terminal
sudo echo "extension=solr.so" > /etc/php5/apache2/conf.d/solr.ini
and restart apache
sudo /etc/init.d/apache2 restart
PHP-SOLR client is installed and ready to use.. :)

If you are working in Ubuntu Nginx and php-pfm then try this.
sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev
sudo apt-get install libpcre3-dev
sudo pecl install -n solr
Create solr.ini file
sudo echo "extension=solr.so" >/etc/php5/fpm/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cli/conf.d/solr.ini
Restart Nginx and php-fpm
sudo restart php5-fpm
sudo service nginx restart

in Debian Linux :
sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev libpcre3-dev php5-dev
sudo pecl install -n solr
sudo echo "extension=solr.so" >/etc/php5/fpm/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cli/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cgi/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/apache2/conf.d/solr.ini
sudo /etc/init.d/php5-fpm restart
sudo /etc/init.d/apache2 restart

In CentOS, execute the following commands:
Install the dependencies:
yum install curl-devel libxml2-devel
Install solr module
pecl install solr
Add solr.so extension to php.ini
"extension=solr.so"
Restart Apache:
systemctl restart httpd.service

Related

How to install php-memcache in xampp ubuntu?

I have installed xampp for linux from https://www.apachefriends.org/index.html in my Ubuntu 22.04 OS
After successfully installed, my project is running fine but when I install the php-memchached in my system with the below command but it is not showing in my phpinfo() page.
Command:
sudo apt-get install -y php-memcached
Also I tried with the code to check my Memcached Successfully installed or not. But I got the error message that Class 'Memcached' not found
Code:
$memcached = new Memcached();
$memcached->addServer("127.0.0.1", 8080);
$response = $memcached->get("sample_key");
if($response==true) {
echo $response;
} else {
echo "Cache is empty";
$memcached->set("sample_key", "Sample data from cache") ;
}
Error Output in Yii console:
Class 'Memcached' not found
Please let me know how to install the php-memcached in Xappp for my ubuntu system?
php-memcached extension uses the libmemcached library to provide an API for communicating with memcached servers.
So, This extension requires libmemcached client library.
The steps. Tried successfully from a basic ubuntu:22.04 image:
FROM ubuntu:22.04
RUN apt-get update && apt-get upgrade -y && apt-get install -y net-tools sudo wget nano
And xampp install:
cd /home
sudo wget https://downloadsapachefriends.global.ssl.fastly.net/8.1.6/xampp-linux-x64-8.1.6-0-installer.run
sudo chmod 755 xampp-linux-x64-8.1.6-0-installer.run
sudo ./xampp-linux-x64-8.1.6-0-installer.run
Then, there are a lot of dependencies to install:
sudo apt-get update
sudo apt-get install -y memcached
sudo apt-get install php-pear
sudo apt-get install libcurl3-openssl-dev
sudo apt-get install php-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libmemcached-dev
sudo pecl install memcached #note the path to memcached.so
sudo nano /opt/lampp/etc/php.ini
add extension=/usr/lib/php/20210902/memcached.so #path noted before
sudo /opt/lampp/lampp restart
Or another possible install:
sudo apt-get update
sudo apt-get install autoconf
sudo apt-get install build-essential
sudo apt-get install -y pkg-config
sudo apt-get install zlib1g-dev
sudo apt-get install libmemcached-dev
sudo /opt/lampp/bin/pecl install memcached #note the path to memcached.so
sudo nano /opt/lampp/etc/php.ini
add extension=/opt/lampp/lib/php/extensions/no-debug-non-zts-20210902/memcached.so #path noted before
sudo /opt/lampp/lampp restart
With your code:
$memcached = new Memcached();
$memcached->addServer("127.0.0.1", 8080);
$response = $memcached->get("sample_key");
if($response==true) {
echo $response;
} else {
echo "Cache is empty";
$memcached->set("sample_key", "Sample data from cache") ;
}
Results:
Cache is empty
And phpinfo:
Reference for more details:
https://www.php.net/manual/en/book.memcached.php
Steps for installing php-memcached in ubuntu
first, go to the /opt/lampp/bin/ then run the below command
> sudo apt-get install libmemcached-dev
> sudo pecl install Memcached
OR
> /opt/lampp/bin/pecl install memcached
Once installed then open php.ini(my ini path /opt/lampp/etc/php.ini) and add the below line in that file
extension=memcached.so
Finally, restart XAMPP
> sudo /opt/lampp/lampp restart

Can't reinstall php7.3 on debian

For some reason, my php cli switched to 5.6.40 instead of the 7.2 version that I had before. Then I was unable to restart apache2, so I tried to apt purge php7 & php5 to reinstall them.
But now, I only have this error:
(sorry for the French, it says packages have unsatisfied dependencies). How can I clean it ?
I have already tried the following commands :
apt-get -f install
apt-get clean
apt-get update
apt-get upgrade
You have to purge comlete php7.3:
sudo apt-get remove -y --purge php7.3*
add repository (if not exist):
sudo add-apt-repository ppa:ondrej/php
install dependents
sudo apt install php libapache2-mod-php
if you have apache:
sudo systemctl restart apache2
if you have nginx:
sudo service nginx restart
install php:
sudo apt install php-fpm
check php:
sudo service php7.3-fpm status

Change version from php 7.0 to 7.1 not working

I have recently change my php version 7.0 to 7.1
I tried
sudo apt-add-repository ppa:ondrej/php
sudo apt install php7.1
sudo a2dismod php7.0
sudo a2enmod php7.1
sudo apt-get install php7.1-xml
Then when i hit localhost/projectname nothing will displays.. and when u hit http://localhost/phpmyadmin/ got
phpMyAdmin - Error The mbstring extension is missing. Please check
your PHP configuration.
then i tried
sudo apt-get install php-mbstring
Nothing change.
finally
sudo service apache2 restart
No change..even i didn't get my project which is worked before.
please help me
Follow list of commands
sudo apt-get install php7.1-mbstring; #version specific mbstring
sudo apt install php7.1-mcrypt;
sudo systemctl restart apache2;
sudo phpenmod mcrypt; #enable mcrypt
sudo phpenmod mbstring; #enable mbstring
sudo systemctl restart apache2;
Caution when you switch version on ubuntu, it automatically removes some version specific extensions. You again have to explicitly
install and enable it
Please try:
sudo apt-get install php7.1-mbstring
sudo service apache2 restart
Hope it helps.

How to install memcached with php 7.1 in centOS?

I've tried following commands:
sudo yum -y update
sudo yum install -y libevent libevent-devel
sudo yum install -y memcached
sudo yum install -y php-pecl-memcache
sudo service memcached restart
sudo service httpd restart
I can see only memcache module which is installed after run above commands.
Finally got Solution!
I've done some research on installation any module for php 7.1. I got success while run below command:
sudo yum install -y php71-memcached [use 72 instead of 71(php version) for php7.2]
I think you had tried commands from this link, but all are not working :D
https://devdocs.magento.com/guides/v2.3/config-guide/memcache/memcache_centos.html

Laravel Not install composer error

Actually, I don't understand what's the problem going on
You can install the zip extension for php 7 on ubuntu by using the ssh command line:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
try
sudo apt-get install php-zip
And then you need to restart apache to include this extension:
sudo service apache2 restart
As mentioned, it requires the zip extension.
You can install it by running:
sudo apt-get install php7.2-zip

Categories