Archive for the ‘php’ Category

01
Mar

PHP 5.4 Officially released

PHP 5.4 was officially released as a stable version. There are some new features on this PHP version, but maybe the surprisingly one is: it comes with a built-in web server for development purposes.

What’s new on PHP 5.4 (Key Features) :

  • Traits
  • Shortened Array Syntax
  • Built-in web server for development purposes

13
Apr

Magento removing admin notifications – Quick tip

If you are a developer and need to login into Magento admin area, you’ll get sick of popup notifications messages all the time. Removing such messages is a straigh forward process.

Just go to System -> Configuration

Select Advanced from the bottom left column

Look for Mage_AdminNotification option, and select Disable from the drop-down.

And that’s it.

Let me know what tips do you want to see about magento.

24
Jan

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',
                                'port'=>465,
                                'auth' => 'login',
                                'username' => 'youremail@gmail.com',
                                'password' => 'YOUR_PASSWORD');
                $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $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");
                $mail->send($transport);

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.

04
Nov

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
$c('ford');

02
Nov

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.