Class 'NumberFormatter' not found in Laravel 5.4 - php

I'm trying to use PHP's intl extension to convert amount into words. For example,
1450 -> One Thousand Four Hundred and Fifty
I'm using Laravel 5.4 that runs on XAMPP 3.2.2 server with PHP 5.6.24.
As mentioned in similar questions, I've already enabled the intl PHP extension by uncommenting the line as extension=ext/php_intl.dll in PHP.ini file and restarted my server after.
$inWords = new \NumberFormatter('en', \NumberFormatter::SPELLOUT);
echo $inWords->format(1450);
yields the error:
FatalErrorException: Class 'NumberFormatter' not found
I'm guessing this doesn't have anything to do with Laravel but PHP. Anyone know the solution to the problem? Thanks for your time.

You have to enable the extension in your php.ini by uncommenting the line
;extension=php_intl.dll

You need to use
use \NumberFormatter;
At controller

Related

PHP extension stats

I'm using PHP in combination with Xampp and have installed the extension stats for Windows (https://pecl.php.net/package/stats/2.0.3/windows). Phpinfo says everything works fine. Stats is enabled. Nevertheless I am getting the error message
Uncaught Error: Call to undefined function stats_rand_gen_ibinomial(),
when I am using the function stats_rand_gen_ibinomial, which is documented here https://www.php.net/manual/en/function.stats-rand-gen-ibinomial.php.
Have you got experiences with these extension?
In php.ini i have added the following line: extension=stats
My first thought was that you need to restart the apache but the output in the screen seems to be be ok, then I executed ">php -m" and the extension was listed but when I run a script calling stats_rand_gen_ibinomial() it fails(exactly what you describe).
I download the source code 2.0.3 and 2.0.0 and the method is not included!!, the same with 1.0.5 and 1.0.4. The last version when the method does exist is : 1.0.3.
You can download all the versions here https://pecl.php.net/package/stats and look for the last one with that method definition. But the conclusion is that for some reason that method is not included . I ignore the reason.

FOSuserBundle and php 5.5

Ive searched the PHPuserBundle documentation and cannot find any reference to php version support issues.
Ive just upgraded my php version to 5.6 (using XAMPP) and I get the following error when sending to login_check.
Attempted to call function "mb_convert_case" from namespace "FOS\UserBundle\Util
Is it best to stick with 5.4 for now? I tried 5.5 and got the same error. My only reason for wanting to upgrade was to stay up to date, so its not life or death but Im curious.
thanks.
Try to uncomment/add this line in your php.ini:
extension=php_mbstring.dll
Latest version ("friendsofsymfony/user-bundle": "2.0.*#dev") of FOSUSerBundle works with PHP>=5.3.2.
You can check this in packagist.org - https://packagist.org/packages/friendsofsymfony/user-bundle
If you are working under Windows then you must uncomment php_mbstring.dll in php.ini file. Check this answer - mb_convert_case undefined function (Symfony2 FOS/UserBundle)

Class 'Yaf_Application' not found

Is anyone know the Yaf Framework ?
I tried to run their sample code from the site and I got the error
Fatal error: Class 'Yaf_Application' not found.
I used the version 2.2.9 , I downloaded the binaries php_yaf-2.2.9-x86-5.4.x-nts-nodebug.dll
as extension of my PHP 5.4.3 and activated the extension.
I put , as suggested, yaf.use_namespace = 0 without success.
Thank you for your help
I have also faced same problem, after some google, I am able to fix this issue.
If you ae using wamp and Win32 means, in php.ini add the following line after extension=php_yaf.dll
yaf.use_spl_autoload=1
yaf.use_namespace=1
I found that my dll does not run on 64bit operating system

Class 'Memcache' not found & PHP

I installed memcached by reading this article on Windows7 but unfortunately i keep getting error Fatal error: Class 'Memcache' not found in D:\xampp\htdocs\test\memcache\test.php on line 2
Line 2: $memcache = new Memcache;
Win7 64, Xampp Installed. I am using net start "memcached Server" on command line but it says service is already started.
Some other info which may help;
On php.ini file:
extension=php_memcache.dll
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211
Update: phpinfo(); show dll is not loaded. Tried several different dll files so far, didn't work. Also dll is located correct. It is in the right folder as it seems.
(P.S. Some may think there are possible duplicates about this topic but there is only 1 person who followed the same instructions and had same error in SO. That question has no answer or solution since march.)
I found the working dll files for PHP 5.4.4
I don't knowhow stable they are but they work for sure. Credits goes to this link.
http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip
http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip
It is the 2.2.5.0 version, I noticed after compiling it (for PHP
5.4.4).
Please note that it is not 2.2.6 but works. I also mirrored them in my own FTP.
Mirror links:
http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.zip
http://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip
Add this to your php.ini:
extension="php_memcache.dll"
and restart apache
Memcached just uses standard text interface so its possible to use it without the module.
// connect
$link = fsockopen($host,$port,$errno,$errst,$timeout);
// set
$data = sprintf("set %s 0 %s %s\r\n%s\r\n",
$key,$expire,strlen($value),$value);
fwrite($link,$data);
$result = trim(fgets($link));
if ($result == 'ERROR') {
// :(
}
// get
$data = sprintf("get %s\r\n",$key);
fwrite($link,$data);
$line = rtrim(fgets($link));
if ($line != 'END') {
return rtrim(fgets($link));
}
So i have looked now for a solution. Here you can download some compiled extensions.
http://downloads.php.net/pierre/
The problem is that at the moment there is no memcache extension for PHP 5.4. this is the problem why your extension could not be loaded. You need the extension for the correct PHP version and Tead Safe for Windows.
So the easiest way is to work with PHP 5.3 if you need the extension.
The newest version of memcache is the version 3.0.6 but its a beta version you can see it here.
http://pecl.php.net/package/memcache
You could try to take the beta version and compile it with your windows system. But its a lot of work.
Also problem can be in loading another version of php module somewhere in apache .conf files. Need to check duplicated "LoadModule php..." directives and if that module compiled to correct version of apache.
It seems sound simply, but not when you have several versions of php on one machine :)
Or it can be SElinux problem too.
xampp windows version is 32bit ,you must be use 32bit memcache.dll
I hole that would be useful for you!

xapian on CentOS 6 with PHP 5.3+

I've got a 64bit server with CentOS 6 and PHP 5.3 installed
php-5.3.2-6.el6_0.1.x86_64
I've installed xapian using RPMs from their website
rpm-eprints-org-xapian-6-1.noarch
xapian-bindings-php-1.2.7-1.x86_64
xapian-core-libs-1.2.7-1.x86_64
xapian-bindings-1.2.7-1.x86_64
xapian-core-1.2.7-1.x86_64
Now when I try to use the xapian library from PHP through Apache, I get this error:
Call to undefined function dl() in /usr/share/php/xapian.php on line 22
After some Googleing I found that dl() is no longer working in PHP 5.3+. I've enabled enable_dl in php.ini, didn't do anything. I've not been able to find any solution to this problem anywhere. I guess there aren't many people using CentOS 6 at the moment?
What can I do?
Since the xapian-bindings are a PHP-extension you could just load it by adding the following to your php.ini:
extension = xapian.so
Btw. the dl-manual says that dl is just disabled for certain "SAPIs" (and apparently mod_php is one of them).
One alternative would be to try php-cgi.

Categories