PHP

UTF8 double encoding issues in web apps and MySQL

I have seen this issue many many times throughout my career so i thought it might be worth to go through it in details and help others.

If you have international content in your database and suddenly you see things like "é" or missing characters like "?" instead of "è" you may be in trouble. It is a symptom of lack of consistency in the ways you write, read and store unicode characters.

I hope my explanation, even that lengthy, will shed some light on the core of the problem and possible solutions :)

Screencast - phpProxyBuilder - proxy design pattern and AOP for PHP

I am very happy to share my first-ever screencast.

Screencast is about my open source project called phpProxyBuilder. It is a PHP library aimed at code reuse and promotion of proxy design pattern in PHP. It is heavily inspired by AOP and helps to implement cross-cutting concerns once and reuse the same code forever. It also promotes some of my favourite design principles like decoupling, testability, single responsibility and code reuse.

I wanted to create some screencasts for a while but I found it difficult to get the right tools. Fortunately screencasting and video editing are much easier on linux now and i hope to share more screencasts about PHP, open source and software design in the future :)

Review - MongoDB the definitive guide

I have read about mongodb quite a lot on-line last year and i also managed to pick up this book. I think it is a really easy to read and well written book. If you want to get some good basics on mongodb i think it is worth checking it out.

It is structured more like a tutorial / reference manual i guess as it focuses a lot on practical examples and usage of different commands.

Cacti graphs generator class for custom metrics import

Cacti is an awesome tool but it requires quite a lot of manual work to setup new metrics measurement and begin graphing. As i am a total monitoring freak i love to have insight into different aspects of my applications. I love to export custom metrics and graph them in cacti but i found it too time consuming so i hacked a cacti graph and input method generator this weekend. The code is a bit primitive so please forgive me but i needed it to do just one particular thing it is not a multi purpose code really :)

I think some of you may find it useful as learning cacti for the first time and manually setting up custom graphs can be difficult so this script should help, check it out.

Why ftp_get and ftp_nb_get may fail with a broken pipe error

That is just a quick hint about an issue i had today. I wasted so much time trying to find the cause of it when at the end it was just no space on the device!

If you have issue with ftp_get or ftp_nb_get and all you see in log is "ftp_get(): Transfer aborted. Broken pipe,,PHP code: 2" then it might be as in my case no space left for the target file!

Review - RabbitMQ in Action

First of all i would be lying if i said that i did not like RabbitMQ :) It is a pretty cool piece of software. Having said that, i could be a bit biased in favor of the technology but i will try my best to be objective here.

RabbitMQ in Action is a really nice book. I think Alvaro Videla and Jason Williams did very good job at describing how to use and leverage RabbitMQ in your web applications.

PHP stomp client customisation for RabbitMQ to properly ACK messages and disable prefetch

Just a quick post to help out anyone who might be stuck on this one. If you are trying to use PHP stomp client from fusesource together with rabbitmq stomp plugin you will probably get same issues that i did. Here are some notes that should help you solve the problem. Hopefully it will be integrated into the 2.0 client.

Publishing queue messages from PHP using different backends

I have looked at the state of different messaging backends recently and i ran a little benchmark to see what is the rough comparison of message publishing throughput. Results that i got are quite surprising.

UPDATE 2012.04

What i wanted to achieve was some sort of reassurance before choosing a messaging bus for my PHP project. PHP is usually a bit special as it's runtime environment is different than java / .net. I wanted to use rabbitmq because of it's routing flexibility and implementation of AMQP. After the simple benchmark i am not convinced any more if that is the best way to go for me right now.

How to install pecl amqp extension in your PHP on ubuntu 11.10

Pecl extension does not compile with the version on rabbitmq-c library shipped with ubuntu so you will have to manually install the library. Here is step by step guide how to do it.

Symfony2 meets Drupal8 + Varnish and ESI

I don't know if everyone will agree and notice the significance of this event but for me this is a MAJOR milestone in PHP community evolution. Drupal 8 will integrate with Symfony2. THIS IS GREAT NEWS!

I always liked Drupal. It is amazing! Community is huge and provides thousands of modules to solve almost any web-related needs you may have. To make it really embarrassing for the enterprise-level CMS solutions, Drupal often beats them in terms of features and quality. I have seen enterprise-level CMSes and they were just a legacy JUNK! There is no question about it, Drupal is awesome! Symfony2 is the sweetest PHP framework there is. Great architecture, patterns, cleanness, consistency, interfaces, testability, dependency container - basically all you need.

How to unittest a failure of fopen using phpunit? - how to temporarily disable convertWarningsToExceptions?

Just a very quick tip on how to test for warnings that may happen in functions like fopen. PHP does not treat errors in unified way some of them rise warnings, some of them throws exceptions others return 0,false or -1 or some other value to indicate an error. How do you deal with them in PHP Unit?

A few words on bugs and software quality

From time to time I see bugs in the code and I start thinking "really? is it possible that no one noticed that bug before? am i the first person to see this code?". I thought it might be worth writing a little post on what helps me to deal with bugs and software quality in general and what are the common pitfalls in developer's thought process. Although it is not a very extensive post i hope it may inspire some developers to try new approaches :-)

In general it is extremely rare for me to commit bugs that would make it into production (maybe less than one a year? hard to say as it is really rare). To be honest I can't remember a serious issue with my code for last 5 years.

How to build mongodb pecl extension in 32bit for PHP 5.2 on MacOSX Snow Leaopard

Unfortunately i have to support PHP 5.2 and i also need to run my Mac in 32 bit mode as my VPN client does not support 64 bit :(

This causes quite a lot of hassle as PHP 5.2 is less and less supported by frameworks, extensions etc. It is also waste of time as i have to manually build stuff instead of using regular packages, ports etc.

Here is a quick step by step guide on how to get mongodb and PHP5.2 mongo pecl extension going on your MacOSX in 32bit mode!

NOTE: 32 bit mongodb binaries have 2GB address space limit so you wont be able to process too much on your laptop. You will still be able to code and connect to remote instances just fine.

How to automate testing of a mobile domain redirections with jmeter

There are many ways to implement mobile version of your website but easiest and probably cleanest one is to use mobile subdomain.

Once you have your mobile website you want to implement an automated test suite to be able to regression test the functionality after every release. You also want the test suite to be easy to configure and run it against test environment. In perfect world you want the test suite to run as part of the continous integration setup. Jmeter allows for all of that and is free. As a huge fan of jmeter i recommend you download it and play around with it as soon as possible.

In this article I describe how to create a test suite for mobile website redirects, you can also download my jmeter test plan and customise it to test your own websites.

How to properly secure remote API calls over SSL from PHP code

Lets make something clear from the very start: JUST BECAUSE THERE IS https:// IN THE URL OF THE REMOTE SERVICE IT DOES NOT MEAN THE CONNECTION IS SECURE!

I am sorry for the tone of this post but i am enraged by how popular this issue is online. If you ask why i suggest a little experiment.

Steps to follow

  • Change your host file settings to point something like www.somedomain.com to your development server
  • Create a self signed certificate for this domain and setup a https virtual host to serve it on local IP or alias
  • Put a test file on that URL
Syndicate content

About the author

Artur Ejsmont

Hi, my name is Artur Ejsmont,
welcome to my blog.

I am a passionate software engineer living in Sydney and working for Yahoo! Drop me a line or leave a comment.

Follow my RSS