Intl PHP extension not working - php

I want to use https://github.com/juriansluiman/SlmLocale module in zend framework-2 and need intl extension, I have installed using pecl and it show success. I had added
extension=intl.so
and restarted my MAMP-Pro, I had tried other links as well:
http://mynameispagewood.com/web-development/how-to-enable-intl-extension-mamp-osx-10-9-2/
http://codingexplained.com/operating-systems/mac/installing-php-intl-extension-os-x-mavericks
to enable it but its not working.
note: No error while starting apache
Is their any alternate method to enable it?
Any light on the path would be helpful
Thanks

You will need to ensure that the version of php being called is in the install path for Brew, otherwise it will be picking up the native installed php

The problem can be solved by first checking the php version in the terminal.
The which php command will print the /Applications/MAMP/bin/php/php7.1.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.
and then check
echo $PATH
/Applications/MAMP/bin/php/php7.1.8/bin/php
If this is right, then no need of installing intl extension, restart MAMP PRO, then it should work.

Related

How to reinstall PHP cURL on Xampp Windows 10?

I am currently having a problem where it looks like PHP cURL 7.76.1 is not working with PHP 8.0.8. i already checked my php.ini file and the extension has been enabled, also when checking phpinfo.php i see a section called curl which means it recognizes the extension. I would like to know if it is necessary to reinstall the extension or maybe upgrade to a newer version if available and how i need to do that.
php8.0 should have php8.0-extension-name installed.
sudo apt install php8.0-extension_name

Install PHP 7.0 Internationalization extension (Intl) on XAMPP on Mac

I followed the instructions outlined here:
Install PHP Internationalization extension (Intl) on XAMPP on Mac
Ran sudo pecl install intl
selected the correct files from the Cellar
then this error happened:
/private/tmp/pear/temp/intl/intl_error.h:24:10: fatal error:
'ext/standard/php_smart_str.h' file not found
include
^ 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failed
No matter, did some research and found out that PHP 7.0.8 deprecated php.smart_str.h to php.smart_string.h
So given my scant knowledge of C++ I copied smart_string.h to smart_str.h and renamed all the headers from STRING to string.....
re-ran pecl -no luck....more errors......without knowing where the .c files are and remaking php (not really interested in going that far) since anyway I'm using XAMPP so that ended that option.
I have php 5.5 on my mac, deep in the usr/local/bin folder
so next step was to get pecl to use those files and generate an intl.so file....
Did that....I have the intl.so file so put it in the 'extensions' folder in XAMPP (for reference: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012)
Ran php and came up with this error:
Warning: PHP Startup: Unable to load dynamic library
'/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so'
- dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so,
9): Symbol not found: _zval_used_for_init Referenced from:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
Expected in: flat namespace in
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
in Unknown on line 0
I imagine it has to do with different versions?
In any case I can't get pecl to install intl without a make error in PHP 7.0.8 on XAMPP. There is no documentation on this and you'd think that if you deprecate a header.h file you'd update all extensions?
Install intl.so in PHP 7 seems impossible?
After a lot of research I was finally able to resolve this. Detailed steps here:
before you begin, check which php path is set. it should be /Applications/XAMPP/xamppfiles/bin/php. If not you can change it by PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}". more detail here
Overall idea is to build the intl-extension from PHP source code on your own. Before you begin make sure you have installed Xcode. Also, install the latest version of autoconf. this might help:
brew install autoconf
Next download the version of PHP you use in XAMPP from php.net. I am using 7.1.18. This version worked for me: php-7.1.31, I’m guessing if you follow the steps it might work for 7.0 or 7.2 as well. Do let me know if it does or doesnt, I’ll update this post. Do not use PHP 7.3 for Magento 2.3.0, it is not supported.
Extract the tar.gz file using (I extracted it inside ~/Downloads/ folder )
tar -xzvf php-7.1.31.tar.gz
cd into the extracted folder
cd php-7.1.31
change to subfolder ext/intl
cd ext/intl/
Run these commands to build the extension
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install
you can now delete all files you downloaded and also the extracted folders.
Open /Applications/XAMPP/xamppfiles/etc/php.ini , and add extension=intl.so
Restart your Apache using XAMPP GUI and it should work.
So far, it seems that extension intl.so for php is bundled with php
and should be compiled with php (intl --enabled). XAMPP does not support this (as of Oct 2016), MAMP does. I do not know about other distros. However, if you're willing to recompile PHP 7, it's worth it just to do that and enable it during compiling.
So....I ran with MAMP. Then I decided that I would simply install apache 2.4 and php 7 and Mysql without the stack and the junk that comes with MAMP or XAMPP and everything works like a charm... so if you need to use CakePHP or intl support etc... just drop XAMPP/MAMP and go with a standard install. I used homebrew (MacOS) and everything is working fine.
Update: As regards Windows, XAMPP does not default it, but you can add the module (dll) in php.ini and works like a charm
The error means that XAMPP doesn't have PHP compiled with intl. You may try:
pecl install intl
but probably it won't work as well.
See: PHP Bug #72879 Pecl install intl make error with PHP 7.0.8.
As for the workaround, try installing memcached extension instead of memcache, e.g.
pecl install memcached
Note: It also requires libmemcached package/library to be installed beforehand. For macOS, install via: brew install libmemcached.
If you wanna try without homebrew, with native apache and php, look at my aswer here: https://stackoverflow.com/a/55131868/3692846

Mailparse and PHP 5.6.2?

Is there a version of Mailparse that works with PHP 5.6.2? I installed it this morning using pecl install mailparse and it placed mailparse.so in what seems to be the wrong location and when I view it in Finder it shows up as a document.
I decided for the heck of it to copy it to the appropriate folder and when I execute the code the uses it I get these messages:
Warning: PHP Startup: mailparse: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
These options need to match
in Unknown on line 0
FYI, I'm not a PHP expert by any stretch.
For php 5.6 and debian first install php5-dev module:
apt-get install php5-dev
and next use latest build for php5, which is currently:
pecl install mailparse-2.1.6
If mailparse is already installed you can remove it before any action:
pecl uninstall mailparse-2.1.6
Officially, no, there's not.
http://php.net/manual/en/mailparse.installation.php
Windows users will enable php_mailparse.dll inside of php.ini in order
to use these functions. A DLL for this PECL extension is currently
unavailable. See also the building on Windows section.
It seems to be just a matter of compiling, so anyone should be able to compile it and share the DLL, but as far as I know no one has done this.
mailparse hasn't had a release for some years - though the git repo is showing recent work (April 2015). I recently used it for a project, however the version I used had some issues in decoding the display-name & email from a list of not perfectly formatted string of multiple names.
I've since installed mmucklo/email-parse and I'm using that as a native PHP solution on PHP 5.6.

How to enable SDO in WAMP Server

I want to enable SDO to use SDO_DAS_XML but I'm getting the error "Class 'SDO_DAS_XML' not found". I am using WAMP Server and dont see any setting for it under PHP Settings or PHP Extensions. Please help
This extension is pretty much abandoned, so I wouldn't recommend using it But,
First install the SDO package.
for Linux:
see this dosc for install and edit php.ini:
extension=sdo.so
extension=sdo_das_xml.so
For Windows:
you need to download sdo.dll file extansion and install with this docs and edit php.ini:
extension=php_sdo.dll
extension=php_sdo_das_xml.dll
You will need the SDO package. Unfortunately this package is no longer being maintained and won't compile on Linux and Windows.
You can't just load the existing extension of an earlier version in a newer PHP version (which comes with WampServer).
The latest version of WampServer i could find with the extension php_sdo.dll included is version 5.1.7.4. You can find it here with the outdated WampServer downloads. You can use the top one (WAMP5 1.7.4).
If you use that version of WampServer you can use the menu of WampServer to enable php_sdo in the PHP-extensions. (You will need to uninstall your current WampServer and its services)

CentOS - Mongo class not found in PHP

I need the MongoDB PHP driver on my CentOS 5.4 machine. My PHP version is 5.1.6. I downloaded the RPM and installed it. That created several files in /usr/bin directory. I copied
/usr/bin/mongo
to
/usr/lib/php/modules
which was what extension_dir showed on doing phpinfo();.
I also added
extension=mongo.so
in /etc/php.ini.
However on executing my PHP script, i still get
Mongo class not found.
What's going wrong here ?
Also, my phpinfo() shows PHP version 5.1.6 whereas running PHP from command line shows 5.3.3. Could anything be wrong with that ?
Thanks in advance.
You're saying your webserver and command line PHP report different versions. These are going to be installed in different locations, and their extensions are API incompatible with each other.
When you installed the php_mongo extension, it may have used the command line php to determine the directory to install the extension to.
Make sure you have the correct php_mongo for the php version of your webserver, and it is in the correct extensions directory. (get the directory from the php.ini returned by phpinfo())
I hope you realise PHP 5.1 is also many years out of date. Unless you have a specific reason to use a version that old, you should also look at upgrading to a more recent version.
Edit:
Just read your comment "I must also mention that /usr/bin/mongo is a binary executable file but its not having a .so extension. Im copying it as is to /usr/lib/php/modules"
No no no! :)
This is the mongo command line client. This is not the PHP extension!
You can run a find /* -name "mongo.so" to see where the installer put the file, this will probably also give you an indication of which version of PHP it was installed for.
It looks as though you are confusing the RPM-packages for the MongoDB server with the requirements to install the MongoDB PHP driver. The PHP driver provides access to the server from your PHP applications, and does not install any command line tools.
restart httpd !
yum service httpd restart

Categories