Tag Archives: zend framework

PHP Frameworks

Today I heard an interesting podcast from the guys of PHPSP and during the whole podcast they brought 2 interesting points:

  1. Every developer should participate on a PHP Open Source project so he can not only learn new techniques but also improve his techniques
  2. Zend Framework is definitely not for beginners.
Talking about frameworks is hard and there are a lot to consider and there is even a lot more that can be overlooked, therefore there are a few things that must be considered:
  • MVC
  • it can jumpstart a project and seriously: time is money
  • performance is important and even if the you can’t achieve with the framework, you can achieve it with hardware
  • when choosing a framework, consider age, documentation and online collaboration
  • frameworks are supposed to be a “lego board” where you build things on, in another words, a place where you don’t need to re-invent the wheel
Don’t forget to consider looking into other frameworks. There is always something new, something that you can use on a given project or even use the concept on a new one.
Have fun.

Mobile development with Zend Framework and WURFL

Great video that was posted today on the Zend Developer Zone, check it out:

Build Mobile Apps with Zend Framework and Zend Studio

Mobile applications are booming. Hundreds of thousands of mobile applications are available. Downloads are in the billions. Watch this video to see how you can use Zend Framework and Eclipse-based tools available for Zend Studio to develop a PHP-based mobile application.”


Internationalization and translation of your site with the Zend Framework

I have just spent the last half-hour writing an comment on the Smooka blog (that is from a good friend of mine) and since the comment become a little bit more of a complement of his post. Checking his post about using the Zend Framework for internationalization and translation of your site is a must.

Follow the link: http://www.smooka.com/blog/2010/08/06/zend-framework-translation-internalization/


Error Handling for different modules on the Zend Framework

kill-the-bug

Error Handling is a default form for Exception treatment on the Zend Framework. The Framework will register the Zend_Controller_Plugin_ErrorHandler and this plugin will by default listen to all controllers and it will do whatever you set to do on the ErrorController ErrorAction defined by you.

Give it a check on the framework documentation: Zend Controller Plugins

The trouble starts when you need to have a new way to handle exceptions differently for each module. Let’s say for instance that the default module is the main site and the secondary module is the shopping cart or a cell phone site.

Just to make the example more clear, imagine that for each module you want to have a different way to display a 404 page.

The documentation correctly shows how to set the plugin in order to use another module, but it don’t show you where. For setting up the plugin to accept another controller, action and view to another module you need to set those rules under the constructor of the module bootstrap or under the constructor of the main bootstrap.

Considering that the following is under the bootstrap for the shopping cart module you would have:

public function __construct() {

$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(array(
‘module’     => ‘shoppingcart’,
‘controller’ => ‘static’,
‘action’     => ‘error’
)));

}

For a reason which I could not understand until this moment, placing this plugin register in any other place will not work. Keep digging at it. Upates soon!!!

Have fun.


Zend Framework – Zend Currency

Today I got myself up with searching on Google and trying to understand the Zend Currency (a great way to easily format numbers in currencies format – PHP does have a function but it does not work under Windows) examples in the Zend Framework documentation. Whatever I did it was not working until I have bumped into a help manual from Zend that showed a better example.

Basically, the Zend Currency will totally bypass the parameters in the array and throw an error if the like the examples on the API documentation are set:

$currency = new Zend_Currency(
‘value’   => 100,
‘display’ => Zend_Currency::USE_SHORTNAME,
)
);
print $currency; // Could return ‘USD 100’
In order for this to work you need to first create the Zend_Currency object passing the locale and currency format (or if you don’t pass any parameter, it will just grab the format and locale from the system).
$currency = new Zend_Currency();
echo $currency->toCurrency(100); // could return USD 100
If you need to pass the locale or currency format this is how you can do:
$currency = new Zend_Currency(‘en_US’, ‘EUR’); // set locale to USA and the currency format to Euro
echo $currency->toCurrency(100);
If we do this same example following the API documentation we would:
$currency = new Zend_Currency(array(‘locale’ => ‘en_US’, ‘value’ => 100, ‘currency’ => ‘EUR’);
echo $currency; // doesn’t work unless you set the locale using the Zend_Registry and Zend_Locale
Anyway is worth to log this kind of troubleshoot.
Have fun.

Redis PHP Introduction

I have just came across this article about installing and using Redis database-proxy-cache system with PHP (very similar to memcache). It’s a very detailed article and it also has directions for those who use the Zend Framework.

Anyway, it’s a great reading: Redis PHP Introduction


IoC – Inversion of Container

Today, Mark Richman, has presented me with the IoC concept. Something that I haven’t heard about until now, but it does make a ton of sense.

Basically it says that instead of calling the framework and invoking it’s objects, you would make the framework aware of your objects. How Michael Mattson’s would say, this is the Hollywood Principle: “Do not call us, we call you”.

There are some good proposals of  developing the Injection Container for the Zend Framework, but so far, at this moment looks like there isn’t any really developed therefore you can find a good library to take a look at Symfony Components.

Check out this article from Ibuildings. I has a good perspective of how it could be developed with the Zend Framework.


New resources

Happy Friday everybody ….

2 New resources for you to check out:

  1. Javascript Bookmarklets
  2. Zend Framework and Firebug – Log PHP warning, errors and exceptions

Don’t forget also of the PHPArch Free Webcast today about Running PHP on Windows with Hank Jansen and Zack Owens.

Have fun .. .


Zend Framework Form Decorators

Decorated Zend Form

This is a great tutorial about using the Zend Framework Form Decorators to construct the form in the way that you want them to be.

It’s a very detailed step by step tutorial and an excellent resource.

Check it out at ZendGeek July post : Zend Form Decorators


Zend Framework Tutorials

I was looking for some info about posting an form with the Zend Framework and I came accross this blog – http://ganeshhs.com/ – it has a great amount of tutorials about the Zend Framework, from the basics to some a bit more advanced.

Cool stuff: http://ganeshhs.com/category/zend-framework


%d bloggers like this: