(Re) start of blogging

Its been some time since I’ve last posted anything in my blog – it would happen that I’d feel like posting something in the blog but never actually write anything. Sometimes I’d log into WP Admin to write, but then I’d feel the pressure of upgrading WP to latest version, upgrading the plugins, curate the old posts – so many tasks to take care before I get the peace of mind to write a new piece.

Today I got some time on hand due to me being on home for Eid-ul-Azha and I decided to ease my blogging and thus I moved my old blog to a subdomain (old.phpfour.com) and installed a fresh WP to start with :)

So, what would I write now that I have removed the clutter ? I am planning to write some posts on Symfony2, some on the recent challenges I faced, some on my religious views – that’s so far I can see it for now.

Read More

Concurrent HTTP requests in PHP using pecl_http

The pecl_http extension has a little gem that can be handy at times – HttpRequestPool. Using this, you can send concurrent HTTP requests and can gain efficiency in fetching non-related data at once. For example, from an external source if your application needs to retrieve an user’s profile, their order history and current balance, you can send parallel requests to the API and get everything together.

Here is a simple example code to illustrate that:

Read More

Amazon S3 integration with Symfony2 and Gaufrette

Its amazing how Symfony2 has created an ecosystem where you can just add a bundle to your application and in minutes, you are able to make use of functionality/integration that would take you days to add if you had to code it up yourself. A while ago, I needed to add S3 CDN support to our Loosemonkies application so that the avatars uploaded by job seekers and company logos uploaded by employers would be stored in a globally accessible CDN. I started looking for a ready-to-use bundle that I can just add to the project, beef up a few config and everything else would just work. However, this time the task seemed a bit tough.

After much searching and evaluating, I stumbled upon this wonderful post. The author has shown here how to use Gaufrette and the Amazon AWS bundle together to achieve what I was looking for. It took me a while to follow the steps and finally I integrated it. Then I had a new requirement where I would need to upload assets that have already been sitting in the local, so I would add an additional method in the PhotoUploader class to handle it – uploadFromUrl. It would guess the mime type of the file by extension, as we do not have the mime type handed to us by PHP. It worked beautifully and we were all set.

Sharing the code here in case others find it useful.

(more…)

Read More