Getting comfy with PhpStorm – one of the best IDEs so far!

Beside the frequently asked question “Which Framework is best?” this one is the top in category – “Which one is the best IDE”. People asks this question in morning, afternoon and evening. Every-time, everywhere. I am a big time fan of Netbeans and I left it a few days after it’s release of 6.7. It was so good, heavenly, yummy but I had to leave this old pal because of it’s extreme hunger to the available resources. There was only one thing that time which could compete with the resource hungry netbeans – that is FireFox. But hey, FF is not your IDE after all. Anyway, back to my point – I left Netbeans and started using PhpStorm. I have a company license and I am glad that I made this move. I am not going to preach PhpStorm in rest of this article, but what I will do is sharing my experience with PhpStorm 🙂

1. PhpStorm is fast: Not like a Bugatti Veyron beside your old 4 wheelers, but it’s fast. I was told that 64 bit version is even faster but that was not true in my macbook pro running snow leopard. rather I found that 64 bit version is slightly sluggish and more resource extensive. Whatever, when you make a jump from Netbeans to PhpStorm, you will really feel the speed of everything and if you keep an eye over your system memory, you will surely say “wow!”.

2. The best Javascript and X/HTML Intellisense: I am a javascript developer for almost 8 years by now. I have tried eclipse, some standalone components which could also run as eclipse plugin and Aptana. Aptana was good – I was using aptana mostly because of it’s auto-completion capability of javascript. But I really HATE eclipse. Why? – I will write a separate blog post on that. Now Netbeans has some capability of intellisense for Javascript but when it comes to jQuery (remember, I left NB at it’s 6.7th release) it was frustrating. PhpStorm really is beautiful for this. Just amazing! The format, the auto suggestion, the code completion everything works just perfect. This is one of the main reason why I am sticking with PhpStorm

3. Version Controlling: Ya ya I know, NB got that too. I am not a Netbeans hater, rather I love it. I love how amazingly it changed my world of coding by charging me nothing – zip, zilch nada! So it is merely a selling point for making a move from NB to PhpStorm – but the thing is, support for different VCS in PhpStorm is as good as like the other parts of it. It has fantastic support for Git and Svn, beautiful tools for merging and fixing the conflicts, refactoring and what not. I was feeling at home and to be honest, migrating from NB to PhpStorm didnt feel like I came to the land of aliens just for this. Without integrated support for VCS it would be impossible for me to stay with PhpStorm.

4. Less hungry: Though Steve Jobs said to stay hungry and foolish but please note that he said it only for humans, not to IDEs :P, lol! Ok, so PhpStorm is less hungry to CPU and Memory than NB. I just wish Firefox will be a performer like this one day 🙂 (different story again, sorry I am distracted with too many things at once)

5. Less Costly and a Friendly company: Phpstorm is a developer friendly company. I am using the licensed copy of Zend Studio since 2005 (I got that for free because of being a ZCE and because of winnign some competitions over time) but heck! Zend Studio is costly. That’s fine, Zend Studio is the PHP company and knows inside out of making a PHP IDE. But trust me, PhpStorm is not an alien thing at all – you will not feel “vim” with this excellent tool. PhpStorm can help you code PHP, HTML, CSS and JS with maximum comfort. Yet, it costs much less than other similar IDEs with similar feature set. And what did I mean by “Developer Friendly”? PhpStorm team listens to you. Most of the time you mail them for a discount, they give you some sort of discount without expecting anything from you (I love you, PhpStorm team for this). Even Elite in the class Zend Studio gives some discount some time. But try the same with Elite of the Elites like Coda. They wont take their time to say “Go, fuck yourself!” – I hate Coda, seriously! So rude!

Anyway – that’s a long story. I am very happy with PhpStorm and has recently upgraded my IDE from 2.x to 3.x with their one year full update support (even with major versions :D, Zend you should really think about that with Zend Studio) and living happily ever after. Love you PhpStorm, I really do!.

Get your 30 days trial version of PhpStorm from http://www.jetbrains.com/phpstorm and feel a whole different level of satisfaction 🙂 And surely, dont forget to check NetBeans too, that’s a beautiful piece of tool.

Photos from my recent trip to Rajshahi, Bangladesh

Went to Rajshahi a week ago to take some shots in winter. I love this place and love to drive on the road to Rajshahi. It always feels like I am coming home. Here is a few shots from my last trip to Rajshahi

Bangladesh in winter
Bangladesh in Winter

Hindu Ritual: Guardian of the 200 years old temple playing the big snail
Hindu Ritual - Playing the Big Snail

This guys is in business for last 7 years in the same place on the street. All he sells is egg, mostly in winter. He sells different types of eggs, prepared with mustard oil, salt and onions. And he is one hell of a famous hot boiled egg seller in Rajshahi 🙂
Eggs with mustard oil, onions and salt

In a glass shop in old town
Glasses, anyone?

Reserved Area
Reserved Area

Crossing the river
Crossing the River

This guy is most famous lemon tea maker in Rajshahi. He uses scented ripe lemons, extra sugar and light tea liquor to make it. And it tastes just awesome!
Lemon Tea Specialist

Mustard Flowers
Mustard flowers in a little piece of heaven

Rail track in a winter morning
Rail track in a winter morning

Tea Time
Its Tea time

Hybrid Racing
Hybrid Racing

Used my 5D mark II and 24-105mm f/4 L IS USM to take these shots. You can check out more photos in my flickr stream by clicking on any of the photos above. I would love to see your comments 🙂

some weddings shots I took in 2011 :)

I love to cover wedding, not only because of the payment but also to see all those happy faces around. Its a blessing which you can really feel from inside. Here are a few shots from some wedding I covered in 2011

The Beautiful Smile

The Bride and Groom

The Bride

I see you.

Shadiii - The Premiere show, coming to the theaters near you very soon...

Bride and Groom 17/365

Hasan-Suchi Marriage Ceremony

Helen and Paris :)

You can see more in my flick stream by clicking on any of the pictures above. Would love to hear your comment.

Some of my favorite night shots I've taken in 2011

Somewhere out on mad horizon
Somewhere out on mad horizon 39/365

Speedlight
Speedlight [ E x p l o r e d ]

Capital of Hell
Capital of hell

Serene
Serene

The Journey Begins
The journey begins

Lonesome
Lonely Tree

Home Calling
Home calling

Used my Canon EOS 550D with 18-55mm f/3.5-5.6 and Tamron 17-50 f/2.8 Non VC for most of them. You can check more in my flickr stream (to do so, just click on any of those images). I would love to hear your comments.

Some photos from this week's photography

I take my camera with me almost everywhere I go to avoid missing any interesting moment. And these photos are taken this evening from Pizza Hut in Uttara, Dhaka – where I went to celebrate one of my friend’s upgrading to 5D mark II . Loved their decoration and food, will visit them again for sure.

Chicken BBQ Pizza
Chicken BBQ Pizza

Chicken BBQ Pizza with Stuffed Crust
One slice on my plate

Red Hot Chilli Pepper
Red Hot Chilli Pepper with the pizza, yummy!!!

Chicken bbq pizza with stuffed crust
Chicken Barbeque Pizza with Stuffed Crust

Serving Hot
Serving oven hot in this winter evening

I used my 5D mark II with 24-105mm f/4 L IS USM to shoot these items. Check out my flickr gallery (click on any of these photos to do so ) for more 🙂

You can also purchase any of these photos from my SmugMug Gallery

jQuery Mouse Direction Plugin

jQuery provides support for standard JS mouse events as well as some custom ones. In jQuery it’s easy to capture whether mouse point has entered in the boundary of an object or left from (mouseenter, mouseleave) or something else happened (like click, dblclick etc). But you are in trouble if you need to capture the direction of your mouse. And it would be fantastic if there was a plugin which can fire custom mouse-direction event on any elements which you can then listen to and bind a listener routine.

I wrote this small plugin (jQuery MouseDirection Plugin) this afternoon to trigger eight custom event for any visible element in the DOM structure. Here is the source code. This plugin registers eight custom directional event like up,down,left,right,top-left,top-right,bottom-left, bottom-right and one more generic event called “mousedirection” where you can capture the direction of the mouse using event object’s “direction” parameters (like event.direction)

[sourcecode language=”javascript”]
/**
* jQuery Mouse Direction Plugin
* @version: 1.1
* @author Hasin Hayder [[email protected] | http://hasin.me]
*/
(function ($) {
var options = {};
var oldx = 0;
var oldy = 0;
var direction="";
$.mousedirection = function (opts) {
var defaults = {
};
options = $.extend(defaults, opts);
$(document).bind("mousemove", function (e) {
var activeElement = e.target || e.srcElement;
if (e.pageX > oldx && e.pageY > oldy) {
direction="bottom-right";
}
else if (e.pageX > oldx && e.pageY < oldy) {
direction="top-right";
}
else if (e.pageX < oldx && e.pageY < oldy) {
direction="top-left";
}
else if (e.pageX < oldx && e.pageY > oldy) {
direction="bottom-left";
}
else if (e.pageX > oldx && e.pageY == oldy) {
direction="right";
}
else if (e.pageX == oldx && e.pageY > oldy) {
direction="down";
}
else if (e.pageX == oldx && e.pageY < oldy) {
direction="up";
}
else if (e.pageX < oldx && e.pageY == oldy) {
direction="left";
}
$(activeElement).trigger(direction);
$(activeElement).trigger({type:"mousedirection",direction:direction});
oldx=e.pageX;
oldy=e.pageY;
});
}
})(jQuery)
[/sourcecode]

An here is how you can use it

[sourcecode language=”html”]
<head>
<title>jQuery Mouse Direction Plugin Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.mousedirection.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css">
.container {
height: 150px;
margin: 20px;
padding: 20px;
width: 300px;
border: 1px solid #888;
}
</style>
<body>
<div class="container">
Move your mouse over this box
</div>
<script type=’text/javascript’>
$(function () {
$.mousedirection();
$(".container").bind("mousedirection", function (e) {
$(this).html("Mouse Direction: <b>"+e.direction+"</b>");
});
});
</script>
</body>
[/sourcecode]

To save from the overwork of running a check whether the mouse has entered on the supplied DOM elements (via selectors) I have located the active element under the mouse pointer and triggered the event only on that object – this was a huge performance boost 🙂

Download the complete plugin with the example.html from the link below

Download jQuery Mouse Direction Plugin

🙂 Enjoy!

Which framework is best?

When I started learning programming for internet in 2001, I started with perl. It was a fantastic language and everything was fine. There was absolutely no problem with it. But then, when I tried to host my tiny application in free hosts available that time, I understood that finding a free host for perl was not as easy as finding one for PHP. Though some hosts were offering free perl hosting that time, but there were problems with available modules etc. And I was a noob with very limited resources around me (even I couldn’t access internet all the time, it was costly like hell for me in those days). I started learning PHP. It’s syntax was similar to perl and there was even the friendly “$” sign present, it didn’t take me too much of time to change my application into php. I choose one from the many free PHP hosting providers and my application went live immediately.

Is perl a bad language? Was it a bad language? NO!

But at the end of the day, PHP turns into the best thing for me because there were plenty of resources available, there was a “HELL OF A MANUAL” with user comments and what not.

These days, beginners and fresher asks a common question all the time – “Which framework is best?” . My answer remains simple for them, “none”. If you are planning to learn a new PHP framework or want to choose a PHP framework for your web application, there are some small points you need to consider first.

1. What is my applications going to do?
2. Which framework has a stable community
3. Which framework has good resources available
4. Which framework is under solid development phase and not in a “discontinued” mode?

Once you have the answer, you need to know that there are basically three types of frameworks in nature. Though most of them offers you an MVC or HMVC work flow, yet, they differ in nature.

  • Some Frameworks are too Liberal
  • Some Frameworks are too strict
  • Some of them are over strict and configuration junky

I started with CodeIgniter. It was extremely liberal, allowed me to write very bad code. In those early days, when I was not pretty much aware of the “MVC” convention, I wrote business logic in the controller, even sometime called model from inside a view. I was like “why not? it works” – but I never understood the philosophy of the true MVC application model and continued to write bad code, until I realized the beauty of coding and the value of that in a team work.

I started learning CakePHP, but well, that time its strict coding style and it’s “convention over configuration” started looking awkward to me. Because I had jumped into CakePHP from a comparatively liberal world of programming, CodeIgniter. I learned CakePHP for a couple of months, even used it in a few applications I was working on that time and I gave it up. It was painful for me.

But then, I realized that to write code that you can really take pride on, you must follow the convention. You can’t simply write business logic inside a controller just because you can do it. You should give up your stubbornness. I started again with Zend Framework. We, a small team in leevio spent a couple of weeks learning Zend Framework together. Though it was a bit painful that time with Rob Allen’s tutorial and very very bad official manual where anyone gets lost in a pile of unnecessary talks, ultimately it started paying off. We learned the ZF and helped other people in our team to learn it in a collaborative effort. Zend Framework is a real gem. It’s strict, but it allows you to write bad code too. However, the strictness is not something that can hurt like a framework which I frequently call a configuration junky, like symfony.

I had a hell of an experience with symfony, oh boy! I wanted to give it a try in 2007/08 and then after spending two days with their configuration system, sandbox, blah blah, this and that, i had been finally able to say hello to this world. I was exhausted, my eyes were almost tearing and it didn’t take much time to change my “hello world” into “bye bye symfony” 😛

Long story short, if you are a beginner with MVC and want to learn a framework from the heart, start with Zend Framework or CakePHP. Soon you will realize that you may not have to move or use any other framework unless the situation requires it. Saying that, there are other very good frameworks out there like Yii, CodeIgniter and Kohana (started as a fork of CodeIgniter and later it became what it is now)

And again I am answering the title question “Which frameworks is best” – there is no such “best” thing to be honest. The one that suits your need is the best framework for you.

Developing PHP applications in the cloud with these free cloud hosting providers

CPU and Disk-space are cheap these days. And the more cheaper they become, cloud companies are coming with more exciting deals for you. Some of them are offered in “Freemium” model, some of them are free forever and some of them are like trial plans which is free for a certain period of time. I will be focusing on some of these free cloud hosting options available out there. One thing to note before you proceed – these free cloud hosting options are very good to develop and test your applications (in dev+staging environment) and it may not be wise to deploy the production version of your application with any free plan (Except Amazon AWS’s free tier, its production ready).

Amazon AWS: Amazon AWS is not only a cloud hosting provider but there are LOT MORE under the hood. They offer you cloud servers, messaging gateway, payment service, CDN and many more. Now there is a sweet promotion going on for all new AWS customers. Just register a new account and you will be getting the followings for free, for ONE YEAR long. No catch!

  • 750 hours of Amazon EC2 Linux Micro Instance usage (613 MB of memory and 32-bit and 64-bit platform support) – enough hours to run continuously each month*
  • 750 hours of an Elastic Load Balancer plus 15 GB data processing*
  • 10 GB of Amazon Elastic Block Storage, plus 1 million I/Os, 1 GB of snapshot storage, 10,000 snapshot Get Requests and 1,000 snapshot Put Requests*
  • 5 GB of Amazon S3 standard storage, 20,000 Get Requests, and 2,000 Put Requests*
  • 15 GB of bandwidth out aggregated across all AWS services*
  • 25 Amazon SimpleDB Machine Hours and 1 GB of Storage**
  • 100,000 Requests of Amazon Simple Queue Service**
  • 100,000 Requests, 100,000 HTTP notifications and 1,000 email notifications for Amazon Simple Notification Service**
  • 10 Amazon Cloudwatch metrics, 10 alarms, and 1,000,000 API requests**

Now in above list ** means that upto this quota, it will always remain free forever, and * means that this service is free for one full year starting from the day of your registration.

Hosting on Amazon’s EC2 platform might be a little tiresome for completely new-comers who has limited knowledge on Linux, SSH and Private/Public key management but this article will help you to start quickly. This is one of the most lucrative among all others I will be mentioning in this article.

By the way, you need a valid credit card to register in Amazon AWS program.

PHPFog: There is a new kid in town, PHPFog. Though they are actually developed on top of Amazon’s AWS platform to help developers manage scaling, deploying etc in a painless and easy, everything under the hood style and they are doing good. PHPFog offers you 100MB of free hosting, 15 GB of bandwidth with unmentioned RAM and CPU for six months. No credit card is required to start. Moreover, they made it fairly easy for you to deploy any Zend-Framework or Drupal or Joomla or WordPress based application in the cloud with their pre-configured containers. This is really a decent package to kickstart developing an application 🙂

To start with PHPFog, you need to know git because source code deployment is completely managed using git and git hooks. You may also need to understand how to manage multiple SSH keypair in your machine to get started with PHPFog. Check out PHPFog at http://phpfog.com

PHPCloud This is something VERY new and I heard about it in last week, when one of my colleagues forwarded me the link. At this moment it is invitation based but dont panic, getting invitation will take hardly a day or two. PHPCloud is backed by Zend on top of Zend Application Fabric platform. Once you are done testing your application in phpcloud, you can keep it either here or deploy to other cloud providers like Amazon EC2, Rackspace or Rightscale. The configuration of the free tier is not mentioned but as far as I have heard, the free container will remain free forever. Please check out PHPCloud at http://www.phpcloud.com

Heroku: One of the prominent cloud platform provider for Ruby developers collaborated with Facebook last month and started providing free container to develop Facebook applications using PHP on top of their amazing platform. Heroku is good, reliable and it comes with thousands of add-on which you will need to buy while the core container is free for PHP Developers. Check out Heroku’s offer at devcenter.heroku.com/articles/facebook

I hope you find this article helpful for developing and hosting your php application in the cloud, and in the same time check the service they offered and their quality. Enjoy!

Shameless Promotion: If you are looking for any beautiful admin panel theme for your Web Application, then you can check out our Brand new and Shiny admin template Muse at Themeforest from our Themio team.

Muse, Professional and Responsive Admin Panel Template from Themio
Muse, Professional and Responsive Admin Panel Template from Themio

A tiny, open source Flickr Portfolio application

I have created a Flickr Portfolio application which can be linked to your Flickr account, display all your latest Flickr photos and incorporate Facebook like and comments with it.

This application is small, simple and code is well formatted so that you can edit it. All the instructions are provided in the readme.txt file and you can edit the settings in config.php file and instantly get a portfolio live 🙂

homepage screenshot
Flickr Portfolio Application - Homepage

Inner page screenshot
Flickr Potfolio Application - Inner Page

To download the source code, please go to http://photography.ofhas.in and find the download link in the footer.

This application is completely free, open source and you don’t even have to give any attribution to me at all 🙂

Download: http://photography.ofhas.in and find the download link in the footer

Enjoy!