Archive for the Coding Category

Jan 24 2011

Zend Framework : Sending emails using Zend_Mail and Google Smtp

Sending emails using Zend_Mail component from Zend Framework is an easy as it can get task. On a recent project, i needed to configure Zend_Mail to work with Google Smtp server.

Here is a quick how to:

$settings = array('ssl'=>'ssl',
                                'auth' => 'login',
                                'username' => '[email protected]',
                                'password' => 'YOUR_PASSWORD');
                $transport = new Zend_Mail_Transport_Smtp('', $settings);
                $email_from = "YOUR_EMAIL";
                $name_from = "YOUR NAME";
                $email_to = "TO_EMAIL";
                $name_to = "TO NAME";
                $mail = new Zend_Mail ();
                $mail->setReplyTo($email_from, $name_from);
                $mail->setFrom ($email_from, $name_from);
                $mail->addTo ($email_to, $name_to);
                $mail->setSubject ('Testing email using google accounts and Zend_Mail');
                $mail->setBodyText ("Email body");

Don’t even bother to add a different email to $email_from than your Google email, because Google will override your settings by you account email.

Update: Got a tip from Bruno Pedro, Google has smtp sending limits, you can only send up to 500 emails using a Google standard account. Read the Google answer on this limiting issue, for more info.

For a more detailed look, just check out Zend_Mail component page.

Nov 4 2010

Revisiting PHP 5.3 __invoke magic method

PHP version 5.3 introduced a new magic method designed __invoke, this method is called when a script tries to call an object as a function.

The __invoke magic method

< ?php
class Car {
	public function __invoke($v) 
		echo "Just called object as function with parameter '".$v."'\n";
$c	=	new Car;
// Just to make sure we have an object
echo "I am an object of type: ".get_class($c)."\n";
// Now let's use it as a function


Nov 2 2010

Speeding up your application with Cache_Lite

Cache_Lite is one of the fast, light and reliable cache system for PHP. It’s an extremely easy and small learning curve system to work with. This post will try to make you a light introduction to PHP Cache_Lite.

Installing PEAR Cache_Lite

In order to work with Cache_Lite you need to install the PEAR package.

pear install Cache_Lite-1.7.8

Starting with Cache_Lite

Is easy as instantiating the object to start using Cache_Lite.

Mar 7 2010

Blog redesign in progress

As many of you may have noticed, today, a new look and feel is present at the blog, not all the changes were merely visual, as the process is undergoing i will explain some of the changes.


Feb 2 2010

PHPBenelux 2010 – My 5 cents

Now, that i am back home, i can write down my thoughts on PHP Benelux 2010, realized in Antwerp, Belgium.

I just signed out for the conference, without really knowing anyone, except from the blogs and previous presentations, i landed in Belgiun without any real expectations about what i was going to bring back to Portugal form the conference.

The event organization

The venue was nice enough for the event presentation, the reception of the event was just great, no need to be a long time waiting for the badge and no hiccups when asking for it. The conference rooms where nice, talk 2 room chairs where somehow not so comfortable, but in general everyone was happy from what i could see. The schedule was nicely controlled by the organization and no big delays occurred, it’s the first time that i saw no real delays happen on a conference of this size, cheers for you guys.

The speakers

The speakers were just great, a lot of PHP known names in the list, with a set of great talks to deliver. Just loved all, but Lorna Jane and Cal Evans where just great, i had to deliver this opinion.

The talks

Sometimes had the hard job of choosing what talk to see, when some of them just overlap at same time, but i’m convicted that i made a great choice, so what did i saw ?

1. Opening Keynote: – The PHP Universe by Derick Rethans
2. Dependency Injection in PHP 5.2 and 5.3 by Fabien Potencier
3. Get the most out of Solr search with PHP by Paul Borgermans
4. PHP applications/environments monitoring: APM & Pinba by Patrick Allaert/Davide Mendolia
5. PHPillow & CouchDB & PHP by Kore Nordmann
6. Passing the Joel Test in the PHP World by Lorna Mitchell
7. Generating dynamic PDFs using Zend Framework and JavaBridge by Eric Ritchie
8. Closing Keynote: Open Teams by Cal Evans

I just left my comments on, if you’re feeling curious just go on and check the audience comments on each talks.

Some of the presentations are now uploaded into Slideshare, sho go on and check them out: and some photos on Flickr:

In conclusion, the conference was just great, i am extremely happy for making around 1000 miles to go there and meet the people and watch the conference live. It as great to meet Jeremy and Priscilla Coates and quickly meet Lorna Jane.

Congratulations to all the people that put effort on making the conference memorable and see you all soon.