PHP-Blog PHP-Blog
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 :)
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 :)
Last week we had a Yahoo! winter hack day. It was my third hack day in Yahoo! and it was the best one so far! The hack party started at 5pm on Thursday. We hacked all night with some people working throughout the weekend as well.
2012 "winter hack day" was an amazing event. We got so much love from management teams and office folks. We produced over 20 super cool hacks with prototypes of mobile apps, internal tools and all sorts of freakn cool code. It was AWESOME! YO SYDNEY, YAHOO!7 IS IN DA HOUSE!
While working with legacy applications and inherently dirty code you have to find creative ways to make things better. Rewriting / major re-factoring are usually not an option as team does not get enough time to do even basic housekeeping, what do you do then?
I have seen sphagetti code way too many times in my life not to call it an anti pattern. One of the main reasons for sphagetti code is allowing any object in the codebase to talk to any other object. In addition it comes hand in hand with usage of global/static scope and leaking information between application layers.
I recently realised that i have been applying the same pattern for a while now. The pattern i propose is an effort to cluster ugliness and relief rest of the code-base from exploding dependencies.
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.
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.
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.
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.
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.
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
I have been thinking a bit recently how to manage dependencies and how to structure Zend Framework based applications to make the code less coupled, more testable and less dependent on the global scope.
I don't mean to be negative but I am not too happy about the web application structure that most articles and books present. In Zend Framework world controller seems to be the place when things get done. Controller is the workhorse and this is where all the logic seems to be buried. It also seems to me that model in MVC is reduced to database integration but there is no services layer for some reason. Where ever you look you will see the same examples with controller doing all the work and models being simple Zend_Db_Table or Zend_Db_Table_Row instances. You will not see business logic focused classes, Controller or DB Model, thats all you can choose from.
It is a bit frustrating that i have to use mac and can not just use the same system that we have in production but well, that is the standard now. So to make the best of it you have to adapt and learn how to deal with operating system issues ;)
I found it a bit tricky to compile PHP extensions like PECL memcache or whatever on my mac for a few reasons. My mac comes with PHP 5.3 and i need to run my site on 5.2 that i got from MAMP. In addition i have 64 bit system that runs PHP in 32 bit mode so i have to tell compiler to use 32 bit mode only.
Few days ago i had to write a groovy test for a java class and i had a long chain of calls to mock. I was not sure how to test it nicely and i started wondering is there a nicer way to do it in PHP. Usually in PHP there is a nice way to do almost anything :D
I have been working on a little piece of code on the weekend lately and i thought it would be useful to have a numeric range similar to Groovy's range. Maybe there is such code already but quick google search did not give me anything useful so i hacked it together myself.
Later on I thought maybe it would be worth sharing it so here it is.
Please make sure you upgrade your PHP version to the latest version as soon as possible as it has a major security flaw which makes websites subject to the following DOS attack.
All you have to do is make PHP interpreter (older than 5.3.5 or 5.2.17) to convert string "2.2250738585072011e-308" to be casted into a numeric type. So if you have a form that accepts numbers which are then cast from strings into numeric values on server side you are probably affected.
Main Blog Categories
About the author

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 @artur_ejsmont