May 11, 2013

Custom RecursiveIterator

PHP RecursiveIterator and its relatives are quite handy in any tree-related situation. Probably the most used is RecursiveDirectoryIterator for getting all files recursively in a directory. But this family of iterators has some issues to be addressed so that developers do not end up fleeing. First, you must not fear SPL. But there's more. Let's see…

Keep empty directories in git: The VERY easy way

I keep hearing this question over and over in the internets: How do I keep an empty directory in git?
And they're usually followed by a hundred of different answers, mostly "you can't" and very complicated ones.
But, in fact, there is a way that's pretty EASY:

January 16, 2013

Sublime Text 2 snippet Getter/Setter

It's almost a month since I embraced Sublime Text as my daily editor, even for coding. And I love how much easier my life is now. As an example, here's a snippet I just made to avoid writing all that getter/setter bolierplate over and over again in PHP…

October 17, 2012

Symfony2: How to start a new project easily with Composer

Composer is the best thing it happened to the PHP community since PHP 5.3 was released: PHP project dependencies made easy. It's worth the little time you must spent to learn how to use it. I can't recommend it enough.

How can I use this jewel to start a Symfony2 Standard Edition project? Have a look at how easy it is:

Symfony2: Repositories in DIC

Easy recipe to define a Doctrine repository in your Dependency Injection Container:

September 07, 2011

Cross browser Leading Zeros with JavaScript

This is a short entry for further reference

Left padding an integer with zeros was never so easy. Can't believe this ended up working.

function LeadWithZeros(num, pad) {
    return (Array(pad).join('0') + num).slice(-pad);
}

LeadWithZeros(5, 3) === '005';
LeadWithZeros(65, 3) === '065';
LeadWithZeros(120, 3) === '120';

March 15, 2011

!isset, is_null, empty: The Good, the Bad and the Ugly

Hi everyone, you programmers trying to grasp the intricacies of PHP. As coders, our raw material is, and will be, information and knowledge. But lack of knowledge does not give us some information, too? Is of this absence that we will discuss today: How to know if we don't know something in PHP. And our main tools are isset, is_null and empty. Want to know more about them? Which one is The Good, The Bad and The Ugly?