PECL/PEAR behind Proxy How-To

Setting the proxy systemwide These exports can be applied to set a systemwide proxy to your console in Linux and Mac OSX.

Make PECL / PEAR use the Proxy PEAR / PECL won’t use the system proxy, instead you have to set it manually. Due to a bug in those tools, PECL throws an…


Compile PHP 5.6 with pthreads and ZTS Ubuntu/Debian

Compile PHP with pthreads and ZTS on Ubuntu or Debian …and all most common extensions including multi-threading, PDO and mongo extension. 1. Setup your installation path first In the first step, we download the latest PHP sourcecode and download the sourcecode of pthreads and the mongo extension. I know it can be a struggle to…

PHP elephant

Custom PHP error handler not respecting error suppression

When using a custom error handler in PHP, it is going to track all errors, warnings and notices regardless of what you specified with error_reporting();. When using @ to suppress errors or warnings, they still go to the custom error handler.

To respect error/warning/notice suppression whilst in your custom PHP error handler you need…

PHP elephant

Why you can’t put array variables right into a string

Code like this can be seen on SO a lot of times:

What’s wrong with it? It’s first of all, it’s the very opposite of clean and proper code style. Properly:

…is the way to go. Is it only style or is there a serious problem with it? Yep, the serious…

Reserved word `flags` in Zend Framework 1 causing Form issues

I recently found a strange issue when coding a form using ZF1’s Zend_Form in combination with checked checkboxes. The code:

The issue: The first 3 checkboxes are getting displayed normally, with banana and apple pre-checked. The second multiCheckbox renders, but does not have any checkboxes checked. Why: In my case I got it working when I renamed ‘multiCheckbox’, ‘flags’, array( to for example ‘multiCheckbox’,…

Custom image upload with NicEdit

I recently had to implement NicEdit with the ability to upload images to the server. NicEdit uploads images by default to imgur. If you want to change this to pictures beeing uploaded to your own server, you’d either have to change the onUpload event, or you imitate the imgur json response with your own values.…

PHP elephant

configuration container vs globally define()ed contstants

Original thread by Pattle I’m working on a project where all the global constants have been defined in a class called Constants, for example:

Then throughout the code something like Constants::getMaxValue() is used to get the value of a constant. This seems a very strange approach why wouldn’t you just use the define function…

PHP elephant

eKomi PHP library

As I’ve been working with eKomi recently and wanted to share the PHP classes I developed to interact with their webservice. Currently supported register products add product specific marketing research options register orders fetch product reviews Coming next: fetch shop reviews    

PHP elephant

Mastering UTF-8 encoding in PHP

Encoding issues can appear in several locations between backend / database and frontend. I’m going to explain each of those locations and how to properly implement a clean encoding throughout your project. What is a multibyte character? A single byte as in its primitive form is a number between 0 and 255, making up a…

PHP elephant

proper inline variable concatenation in PHP

This shortpost will be about good practice concetanation of variables in PHP and using PHP in HTML inline. My coding style is based on Zend. Concatening variables What you often see is are lines like this:

PHP is able to handle such, but it’s not the proper way of doing it. Not only for…