PHP7.2 missing intl extension - php

I'm trying to run php app that use locale_accept_from_http function from intl extension. My php version is 7.2 and I get an error: Call to undefined function locale_accept_from_http();
I was trying:
1. Install extension sudo apt-get install php-intl.
The error is:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php-intl : Depends: php7.1-intl but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
2. Enable intl extension in php.ini.
I'm getting a warning:
PHP Warning: PHP Startup: Unable to load dynamic library 'intl'
What is the right way to use this extension with php7.2?

As it states in your error, you are having broken packages so in that case, you should try to fix it, probably following commands will fix them.
apt update
apt autoremove
Once you have fixed that issue, you can try executing following commands if you have not added ondrej PPA:
add-apt-repository -y ppa:ondrej/php
apt install php7.2 php7.2-intl

Related

How to install php module intl on ubunut 22.04 with two php versions active - php 8.1 and php 8.2

My worpdress website site health page dispalyas apossible improvement - php module intl missing.
My server has multiple versions of php (8.1 &8.2) active.
I use the following ssh command to install the missing intl module-
apt-get install -y php-intl
But get tis error message.
The following packages have unmet dependencies:
php8.1-intl : Depends: php8.1-common (= 8.1.2-1ubuntu2.10) but 8.1.14-1+ubuntu18.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.
the php modules which are active om my server , like imagick, are installed for php8.1. but my active php version is 8.2.
The problem is with the dependencies of the "php8.1-intl" package. Specifically, it requires version 8.1.2-1ubuntu2.10 of the "php8.1-common" package, but the version that is currently available is 8.1.14-1+ubuntu18.04.1+deb.sury.org+1, which is causing a conflict.
try:
sudo apt update
sudo apt-get check
sudo apt-get install -f
sudo dpkg --configure -a
5.sudo apt-get install php8.1-common=8.1.2-1ubuntu2.10
6.sudo apt-get install php8.1-intl
You may need to remove the conflicting package(s) and installing the required packages again. But be careful when removing packages as it may cause other dependencies to break.

How to download php7.2-gd extension in ubuntu 21.04?

I want to install gd extension in my current php-project(php version is 7.2.34) for that i use this command sudo apt-get install php7.2-gd it's throwing following error and it's not showing in the list when i run php -m command ,How to install gd extension please help me to fix this issue..
Error
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.2-gd : Depends: libjpeg62-turbo (>= 1.3.1) but it is not installable
E: Unable to correct problems, you have held broken packages.
This package depends on libjpeg62-turbo so you need to install it first
wget http://ftp.debian.org/debian/pool/main/libj/libjpeg-turbo/libjpeg62-turbo_1.5.1-2_amd64.deb
sudo apt-get install ./libjpeg62-turbo_1.5.1-2_amd64.deb
after that, you could install your package easily
sudo apt-get install php7.2-gd

Not able to re-install php again on ubuntu

I want to update php version from 7.0 to 7.1 so i tried update php commands to update php version on ubuntu system.
But its not updated, so i removed php 7.0 version using purge command
sudo apt-get purge 'php*'
These are the commands i tried for update php7.1 version after uninstall php7.0
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1 php7.1-common
Getting error in command prompt as
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.1
E: Couldn't find any package by glob 'php7.1'
E: Couldn't find any package by regex 'php7.1'
E: Unable to locate package php7.1-common
E: Couldn't find any package by glob 'php7.1-common'
E: Couldn't find any package by regex 'php7.1-common'
What im missing or did any thing wrong here?
It seems like php7.1 and php7.1-common packages are not available in your apt's sources.
I am assuming you are using the latest Ubuntu 18 LTS.
You could install php7.2 from the repositories, however older versions are not included anymore. You would have to install them manually.
For Version 7.2
sudo apt update
sudo apt install php7.2 php7.2-common
php -v
For Version 7.1
Download php
Extract the downloaded archive
Follow the included readme file
other options
If you are developing with different versions of PHP you might want to look into PHP docker containers
PHPDocker.io can be a good starting point.
EDIT: Also maybe consider posting this question on askubuntu instead, they might have more specific knowledge there.
You need to remove the old version before adding the new one.
Try: sudo apt-get remove php7.0*
Also it is useful to list all php packages to check if you are installing all you need.
sudo apt-get list php*
Then it is safe to run your commands.

PHP intl.so fails

PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20121212/intl.so' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/intl.so, 9):
Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.56.dylib
Referenced from:
/usr/lib/php/extensions/no-debug-non-zts-20121212/intl.so Reason:
image not found in Unknown on line 0
I recently was trying to install MongoDB for PHP, I used
brew install homebrew/php/php55-mongodb
This installed a whole load of other requirements and now intl.so for PHP is broken. I get the above error whenever I run composer update and the libs I have that need intl.so now break and say its not present.
I believe this is related to the issue but it offers no solution https://github.com/Homebrew/homebrew-php/issues/2544
How can I undo this mess?
After more digging I removed, then installed intl using pecl and this seems to have worked. I also removed and then reinstalled icu4c as this is a related package that causes the issue;
sudo pecl remove intl
brew unlink icu4c
brew remove icu4c
brew install icu4c
sudo pecl install intl

Installation pdo_pgsql in Ubuntu10 not working

Am trying to install pdo_pgsql in ubuntu 10.04 and PHP 5.4.37. Actually the postgresql is installed and working properly with phppgadmin.
Now the problem is the pdo driver for pgsql is missing.
I installed pdo for pgsql, when I enter pecl install pdo_pgsql
# sudo pecl install pdo_pgsql
`pecl/pdo_pgsql is already installed and is the same as the released version 1.0.2
And also added a new pgsql.ini file in /etc/php5/apache2/conf.d/ as
extension=pdo_pgsql
when I run phpinfo()
I can able to see
/etc/php5/apache2/conf.d/pgsql.ini,
in Additional .ini files parsed
But I can't able to see the drivers loaded in PDO, only mysql and sqlite have been loaded.
Additional Message I got from server,
PHP Warning: PHP Startup: pdo_pgsql: Unable to initialize module
Module compiled with module API=20090626
PHP compiled with module API=20100525
These options need to match
in Unknown on line 0
FYI,
Even I tried
# sudo apt-get install php5-pgsql
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php5-pgsql: Depends: phpapi-20090626
Depends: php5-common (= 5.3.2-1ubuntu4.30) but 5.4.37-1+deb.sury.org~lucid+1 is to be installed
E: Broken packages
Please suggest me how to proceed further.
I even restarted the apache and server itself.
Thanks
apt-get install php5-pgsql
Try this
-----------------------------------------REMOVE
sudo apt-get purge php5-pgsql
Use this to remove pgsql
Depend what php try with php5-pgsql php-pgsql php4-pgsql

Categories