[PHP] How to install PHP Accelerator in Xampp ?

[PHP] How to install PHP Accelerator in Xampp ?

The PHP Internationalization extension is used, amongst others, by Symfony (for validators).

This extension allows you to write codes like this one :

$formatter = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
echo $formatter->format(1234567.89); // 1,234,567.89

$formatter = new NumberFormatter('fr_FR', NumberFormatter::DECIMAL);
echo $formatter->format(1234567.89); // 1 234 567,89

$formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_CODE); // USD

$formatter = new NumberFormatter('pt_BR', NumberFormatter::CURRENCY);
echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_CODE); // BRL

and so much more, including formatting of currency, number and date/time as well as UCA-conformant collations (customizable method to compare two strings).

To activate this extension in Xampp, just edit your php.ini (i.e. in C:\xampp\php directory) and remove the semicolon to uncomment this line :

;extension=php_intl.dll

Eventually don’t forget to restart Apache !

read more

[PHP] How to install Intl extension in Xampp ?

[PHP] How to install Intl extension in Xampp ?

To install PHP Accelerator in Xampp, you need first to go to your php.ini file (i.e. within C:xamppphp directory) and add this line inside Dynamic Extensions part :

Then you need :

  1. to show you PHP configuration via the PHP function phpinfo()
  2. to get 2 precious informations :


    x86 or x64, and TS (Thread Safe) or NTS (Non Thread Safe)
  3. to download the corresponding DLL (including your PHP version) :
    http://pecl.php.net/package/APCu/4.0.8/windows
    (PHP 7: http://pecl.php.net/package/APCu/5.1.3/windows)
  4. to copy/paste the DLL file within your extensions directory
  5. to edit your php.ini file (i.e. within C:xamppphp directory)
  6. and add this line inside Dynamic Extensions part :
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

[...]

extension=php_apcu.dll

Eventually don’t forget to restart Apache !

read more

[Cordova] How to detect shaking ?

[Cordova] How to detect shaking ?

For I Met, I needed to detect shaking to allow users adding each other to their timeline by simply shaking their phone at the same time. I did a little search and found leecrossley’s shake.js script but it didn’t work well. Thus I slightly improved it to write this one.

read more

[PHP] How to use 4 methods (DELETE, GET, POST, PUT) in a RESTful API client using Curl ?

[PHP] How to use 4 methods (DELETE, GET, POST, PUT) in a RESTful API client using Curl ?

Finishing my first release of PhpRestDoc I had to develop a cross-method solution to allow users to test REST API requesting directly from the documentation and get 3 parts of the API response :

  • HTTP Status Code,
  • Header,
  • Body,

through 4 different methods :

  • DELETE,
  • GET,
  • POST,
  • PUT.

Also I needed to be able to customize the desired content type to get (JSON, XML, etc).

Here is the commented source code that I wrote to achieve that :

read more