how can I install pspell in php5/ubuntu? - php

I am trying to install pspell for PHP 5 in Ubuntu. I have installed the aspell library which is required to run pspell as shown here
I am not sure if there are any settings I need to change, etc.
When I try to execute the below mentioned line of code
$pspell_link = pspell_new("en");
I get an error
Fatal error: Call to undefined function pspell_new()
Any idea on what could be wrong ?
Any help greatly appreciated.

just do
sudo apt-get install libpspell-dev
sudo apt-get install php5-pspell
sudo apt-get install aspell-en
then restart your apache2 server with the following command
sudo service apache2 restart
it will be added automatically to your php.ini
you can try this example

For those using PHP 7.2 / Ubuntu 18.10, here is what I did to get PSPELL working:
sudo apt-get install php5-pspell
sudo apt-get install php-pspell
sudo apt-get install aspell-en
sudo apt-get install aspell-fr
sudo apt-get install aspell-de
sudo apt-get install aspell-es
sudo service apache2 restart
I use multiple languages, so included some of them in the example above. I believe EN is included by default.

"I have installed the aspell library which is required to run pspell as shown here"
that's if you compile your own PHP - did you recompile with pspell?
Note that this package just provides the API and data, you are getting an error becuase your PHP doesn't know how to interface with it.
If you're not into building your own code, the PHP extension is available as a package:
(NB this is JUST the PHP side of the service)
http://packages.ubuntu.com/source/dapper/php-pspell
C.

Have you configured php.ini to load the extension?

Related

laravel composer update : the requested PHP extension dom is missing from your system

I am using ubuntu 16.04, laravel 5.2
when i run update composer in my project directory its showing
"the requested PHP extension dom is missing from your system"
i checked installed packages of PHP, its available there
Installing xml-extension (php7.0-xml in my case) solved the problem
sudo apt-get install php-xml
If PHP version is 7.2, execute the following command
sudo apt-get install php7.2-xml
Managed to fix it with a php version 5.6* :
$ sudo apt-get update
$ sudo apt-get install php5.6-xml
You might have some missing dependencies, so first run
sudo apt-get -f install
Then install php-xml
sudo apt-get install php-xml
This worked for me.
DOM is a PHP extension and not a PHP package. This means that your version of PHP needs to be recompiled with the extension. It is possible however that your PHP was already compiled with DOM but that DOM is not enabled.
You can check this in your php.ini (search for extension=dom.so and make sure it's uncommented).
In my case I use
sudo apt-get update
and
sudo apt-get install php7.3-xml

How to install/enable intl and xsl extensions after installing PHP 7

I installed php7/apache2.4/mysql5.6 via this script, but it turns out that the extensions xsl and intl are missing (need them to run Magento2).
I'm using Ubuntu 14.04.
If it is for dev purposes only, the easiest way would be use a PPA like ppa:ondrej/php-7.0 and then apt-get install php7.0-intl and apt-get install php7.0-xsl. PPAs should NEVER be used in production.
You can run sudo apt-get install php7.0-intl to get it installed.
You dont need PPA adding on 16.10 .
1st you need to add ppa repository to server
this can be done by :
sudo add-apt-repository ppa:ondrej/php
when PPA repo installed, update the local package cache by :
sudo apt-get update
after this you need to run following command to install intl & xsl extensions
sudo apt-get install php7.0-intl
sudo apt-get install php7.0-xsl
check the php extensions by :
php -m
if the extension does load on browser , than you need to check your php.ini for apache2
that can be found by calling <?php phpinfo();?> in info.php file

Class 'DOMDocument' not found

I've found an error on a page in my Magento application; it always show this message error when I visit it:
Fatal error: Class 'DOMDocument' not found in /home/.../lib/Zend/Feed/Abstract.php on line 95
Can you give me a solution? I'm using magento 1.4.1.1.
You need to install the DOM extension. You can do so on Debian / Ubuntu using:
sudo apt-get install php-dom
And on Centos / Fedora / Red Hat:
yum install php-xml
If you get conflicts between PHP packages, you could try to see if the specific PHP version package exists instead: e.g. php53-xml if your system runs PHP5.3.
PHP 8.2
Ubuntu: apt-get install php8.2-xml
CentOS 8 [with php:remi-8.2 enabled]: dnf install php-xml
PHP 8.1
Ubuntu: apt-get install php8.1-xml
CentOS 8 [with php:remi-8.1 enabled]: dnf install php-xml
PHP 8.0
Ubuntu: apt-get install php8.0-xml
CentOS 8 [with php:remi-8.0 enabled]: dnf install php-xml
PHP8: (latest version)
sudo apt-get install php8.0-xml
PHP7:
sudo apt-get install php7.1-xml
You can also do:
sudo apt-get install php-dom
and apt-get will show you where it is.
Package php-dom is a virtual package provided by:
php7.1-xml 7.1.3+-3+deb.sury.org~xenial+1
php7.0-xml 7.0.17-3+deb.sury.org~xenial+1
php5.6-xml 5.6.30-9+deb.sury.org~xenial+1
You should explicitly select one to install.
In case anyone using 5.6 versions then go with this way
sudo apt-get install php5.6-xml
For PHP ver PHP7, Ubuntu:
sudo apt-get install php7.1-xml
or by
yum install php-xml
I'm using Centos and the followings worked for me , I run this command
yum --enablerepo remi install php-xml
And restarted the Apache with this command
sudo service httpd restart
After a long time suffering from it in PHPunit...
For those using namespace, which is very common with Frameworks or CMS, a good check in addition to seeing if php-xml is installed and active, is to remember to declare the DOMDocument after the namespace:
namespace YourNameSpace\YourNameSpace;
use DOMDocument; //<--- here, check this!
Create an empty PHP file and put only <?php phpinfo(); in it, look at it in a browser.
Check if you can spot --disable-dom in the configuration options and/or if you can see details about the DOM extension in the list below.
If you cannot see DOM in the list or you see it is disabled, your PHP installation does not include the DOM extension. You'll need to recompile your PHP installation from source to remedy that.
In my case the problem was it was the use of namespace at the top of php file, exemple :
namespace MediaWiki\Extensions\ParserFunctions;
To solve this problem add the following line:
use DOMDocument;
So no need of installing dom or xml if they are already installed. It is a php language trap.
This help for me (Ubuntu Linux) PHP 5.6.3
sudo apt-get install php5.6-dom
Thats work for me.
For PHP 7.4 Install the DOM extension.
Debian / Ubuntu:
sudo apt-get update
sudo apt-get install php7.4-xml
sudo service apache2 restart
Centos / Fedora / Red Hat:
yum update
yum install php74w-xml
systemctl restart httpd
For previous PHP releases, replace with your version.
Using Suse Linux (Linux linux 3.16.7-48-default) and PHP 5.6.1 as root, this helped:
zypper in php5-dom
plus restart
systemctl restart apache2
On fedora 26:
dnf install php-dom
Fixes it !
If compiling from source with --disable-all then DOMDocument support can be enabled with
--enable-dom
Example:
./configure --disable-all --enable-dom
Tested and working for Centos7 and PHP7
I'm using CentOS 7 with virtualmin and three PHP versions. I also have REMI repo enabled. it worked for me:
Step 1:
Just append PHP major version number like this php{version number}-xml. And run yum install
yum install php70-php-xml
yum install php71-php-xml
yum install php72-php-xml
Step 2:
Don't forget to restart Apache:
service httpd restart
On a Amazon Linux 2 with PHP 8.0, I had to
yum-config-manager --enable remi-php80
yum install php-xml
Do not forget to restart PHP
systemctl restart php-fpm
For Centos 7 and php 7.1:
yum install php71w-xml
apachectl restart
If you are using PHP7.0 to install Magento, I suggest to install all extensions by this command
sudo apt-get install php7.0 php7.0-xml php7.0-mcrypt php7.0-curl php7.0-cli php7.0-mysql php7.0-gd libapache2-mod-php7.0 php7.0-intl php7.0-soap php7.0-zip php7.0-bcmath
I need to Google some times to meet Magento requirement.
I think you can replace the PHP version to 7.x if you use another PHP version
And restart Apache is needed to load new extensions
sudo service apache2 restart
PHP 7.X Centos 7
I got dependency issues when trying to install module with above suggestions, adding this flag:
--enablerepo=remi-php7X
Resolved dependencies.
So
sudo yum --enablerepo=remi-php7X install php-xml
Then
service httpd restart
Ref:
Install PHP Modules
this is the lastest for php v 8.0
sudo apt-get install php8.0-xml

Fatal error: Class 'SoapClient' not found

I'm trying a simple web service example and I get this error even though I uncommented extension=php_soap.dll in the php.ini file:
Fatal error: Class 'SoapClient' not found in C:\Program Files (x86)\EasyPHP-5.3.9\www\server.php on line 2
Diagnose
Look up the following inside your script file
phpinfo();
If you can't find Soap Client set to enabled like so:
Fix
Do the following:
Locate php.ini in your apache bin folder, I.e Apache/bin/php.ini
Remove the ; from the beginning of extension=php_soap.dll
Restart your Apache server
Look up your phpinfo(); again and check if you see a similar picture to the one above
If you do, problem solved!
On the other hand if this doesn't solve your issue, you may want to check the requirements for SOAP here. Also in the comment section you can find good advice on connecting to https.
To install SOAP in PHP-7 run following in your Ubuntu terminal:
sudo apt-get install php7.0-soap
To install SOAP in PHP-7.1 run following in your Ubuntu terminal:
sudo apt-get install php7.1-soap
To install SOAP in PHP-7.2 run following in your Ubuntu terminal:
sudo apt-get install php7.2-soap
To install SOAP in PHP-7.3 run following in your Ubuntu terminal:
sudo apt-get install php7.3-soap
For AWS (RHEL):
sudo yum install php56-soap
(56 here is 5.6 PHP version - put your version here).
To install SOAP in PHP5.6 run following in your Ubuntu 14.04 terminal:
sudo apt-get install php5.6-soap
service php5.6-fpm restart
service apache2 restart
See if SOAP was enabled:
php -m
(You should see SOAP between returned text.)
I had to run
php-config --configure-options --enable-soap
as root and restart apache.
That worked! Now my phpinfo() call shows the SOAP section.
I solved this issue on PHP 7.0.22-0ubuntu0.16.04.1 nginx
sudo apt-get install php7.0-soap
sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx
I couln't find the SOAP section in phpinfo() so I had to install it.
For information the SOAP extension requires the libxml PHP extension. This means that passing in --enable-libxml is also required according to http://php.net/manual/en/soap.requirements.php
From WHM panel
Software » Module Installers » PHP Extensions & Applications Package
Install SOAP 0.13.0
WARNING: "pear/HTTP_Request" is deprecated in favor of "pear/HTTP_Request2"
install ok: channel://pear.php.net/SOAP-0.13.0
Install HTTP_Request2 (optional)
install ok: channel://pear.php.net/HTTP_Request2
Restart Services » HTTP Server (Apache)
From shell command
1.pear install SOAP
2.reboot
For XAMPP users, open php.ini file located in C:/xampp/php and remove the ; from the beginning of extension=soap. Then restart Apache and that's it!
For Docker* add this line:
RUN apt-get update && \
apt-get install -y libxml2-dev && \
docker-php-ext-install soap
*: For debian based images, ie. won't work for alpine variants.
For PHP 7.4 & Docker
add this line in Dockerfile:
RUN apt-get update && apt-get install -y \
libxml2-dev \
RUN docker-php-ext-install soap
Rebuild the image and restart ;)
You have to inherit nusoap.php class and put it in your project directory, you can download it from the Internet.
Use this code:
require_once('nusoap.php');
On Centos 7.8 and PHP 7.3
yum install php-soap
service httpd restart
For PHP 8:
sudo apt update
sudo apt-get install php8.0-soap
In my case, the Symfony cache was causing the problem,
after running composer install the problem was gone.
I had a similar problem. It was due to the scope and solved by replacing new SoapClient by new \SoapClient.

Fatal error: Call to undefined function mcrypt_encrypt()

NOTE: The libraries MCrypt support depend on have not been updated in years and MCrypt should no longer be considered a viable or secure method of encrypting data. What's more, MCrypt has been deprecated in PHP 5, and removed entirely in PHP 7. If you have any code that runs MCrypt you should refactor it to use a more modern encryption library.
Does anyone know why this error message: (Call to undefined function mcrypt_encrypt() ) displays when I run the following code below?
Am I missing some steps perhaps any setting in PHP I have to do before this code can work?
$key = 'password to (en/de)crypt';
$string = 'string to be encrypted';
$test = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key),
$string, MCRYPT_MODE_CBC, md5(md5($key)));
If you have recently updated to ubuntu 14.04 here is the fix to this problem:
$ sudo mv /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
$ sudo php5enmod mcrypt
$ sudo service apache2 restart
What had worked for me with PHP version 5.2.8, was to open up php.ini and allow the php_mcrypt.dll extension by removing the ;, i.e. changing:
;extension=php_mcrypt.dll to extension=php_mcrypt.dll
For windows
;extension=php_mcrypt.dll to extension=php_mcrypt.dll
then restart your apache server
For Redhat
sudo yum install php55-mcrypt //if php5.5
sudo yum install php-mcrypt //if less than 5.4
sudo service httpd restart //if apache 2.4
sudo /etc/init.d/httpd restart //if apache 2.2 or less
For Ubuntu
sudo apt-get install php5-mcrypt
sudo service apache2 restart //if server not reloaded automatically
Still not working?
sudo php5enmod mcrypt && sudo service apache2 restart
If you are using PHP 7.2 or up:
This function was DEPRECATED in PHP 7.1.0, and REMOVED in PHP 7.2.0.
source: http://php.net/manual/en/function.mcrypt-encrypt.php
So you have to replace the php code and find a solution without mcrypt.
Or, I just found out, you can STILL use mcrypt in PHP 7.2.0, but you have to install it as a PHP Extension Community Library. (https://pecl.php.net/)
On Debian/Ubuntu Linux distros:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
then:
sudo pecl install mcrypt-1.0.1
Source: https://www.techrepublic.com/article/how-to-install-mcrypt-for-php-7-2/
You don't have the mcrypt library installed.
See http://www.php.net/manual/en/mcrypt.setup.php for more information.
If you are on shared hosting, you can ask your provider to install it.
In OSX you can easily install mcrypt via homebrew
brew install php54-mcrypt --without-homebrew-php
Then add this line to /etc/php.ini.
extension="/usr/local/Cellar/php54-mcrypt/5.4.24/mcrypt.so"
Under Ubuntu I had the problem and solved it with
$ sudo apt-get install php5-mcrypt
$ sudo service apache2 reload
On ubuntu 14.10 :
Install module mcrypt
sudo apt install php5-mcrypt
Enable module mcrypt on apache2
sudo a2enmod mcrypt
Reload module configuration
sudo service apache2 restart
On Linux Mint 17.1 Rebecca - Call to undefined function mcrypt_create_iv...
Solved by adding the following line to the php.ini
extension=mcrypt.so
After that a
service apache2 restart
solved it...
I had the same issue for PHP 7 version of missing mcrypt.
This worked for me.
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade
sudo service apache2 restart (if needed)
Is mcrypt enabled? You can use phpinfo() to see if it is.
One more thing: if you are serving PHP via a web server such as Apache, try restarting the web server. This will "reset" any PHP modules that might be present, activating the new configuration.
Assuming you are using debian linux (I'm using Linux mint 12, problem was on Ubuntu 12.04.1 LTS server I ssh'ed into.)
I suggest taking #dkamins advice and making sure you have mcrypt installed and active on your php5 install. Use "sudo apt-get install php5-mcrypt" to install. My notes below.
Using PHP version PHP Version 5.3.10-1ubuntu3.4, if you open phpinfo() as suggested by #John Conde, which you do by creating test file on web server (e.g. create status page testphp.php with just the contents "" anywhere accessible on the server via browser)
I found no presence of enabled or disabled status on the status page when opened in browser. When I then opened the php.ini file, mentioned by #Anthony Forloney, thinking to uncomment ;extension=php_mcrypt.dll to extension=php_mcrypt.dll
I toggled that back and forth and restarted Apache (I'm running Apache2 and you can restart in my setup with sudo /etc/init.d/apache2 restart or when you are in that directory just sudo restart I believe)
with change and without change but all no go. I took #dkamins advice and went to install the package with "sudo apt-get install php5-mcrypt" and then restarted apache as above. Then my error was gone and my application worked fine.
If you are using php5-fpm do remeber to restart it, after installing mcrypt
service php5-fpm restart
If you using ubuntu 14.04 here is the fix to this problem:
First check php5-mcryp is already installed apt-get install php5-mcrypt
If installed, just run this two command or install and run this two command
$ sudo php5enmod mcrypt
$ sudo service apache2 restart
I hope it will work.
My Environment: Windows 10, Xampp Control Panel v3.2.4, PHP 7.3.2
Step-1: Download a suitable version for your system from here: https://pecl.php.net/package/mcrypt/1.0.3/windows
Step-2: Unzip and copy php_mcrypt.dll file to ../xampp/php/ext/
Step-3: Open ../xampp/php/php.ini file and add a line extension=php_mcrypt.dll
Step-4: Restart apache, DONE!
In Ubuntu 18.04, and for php7.0
$ sudo apt-get install php7.0-mcrypt
$ sudo systemctl reload apache2
for Linux based (Fedora)
yum -y install php-mcrypt
Enable the module by adding: 'extension=mcrypt.so' to PHP.ini. (/etc/php.ini)
systemctl restart httpd.service
Done!
For me it helped to uninstall mcrypt with:
sudo apt-get purge php5-mcrypt
and simply reinstall it:
sudo apt-get install php5-mcrypt
and dont forget to restart apache as described above.
Dont know why and how this was different in my case (using a vm with provisioned php55), but maybe this will help someone else. I also had this problem with some other modules like xcache...
Check and install php5-mcrypt:
sudo apt-get install php5-mcrypt

Categories