Chris Hartjes writes a very nice article about how to make (re)usable zend_forms; After searching around online for some examples of building simple forms, I was dismayed to discover there were two different ways of building the form. I could (a) do it the long way and create specific instances of the form elements using Zend_Form_Element_X or (b) do it the short way and add them to the form by use of Zend_Form::addElement() and pass it the type of form element I want via an array. For reasons I cannot explain initially, I decided to do things the long way. Later on, I found out that doing it this way saved me from rewriting.
Via: Creating Usable Forms With Zend Framework.
Zend Framework 1.10.0 STABLE Released
On behalf of the Zend Framework team and the framework’s many contributors, I’m pleased to announce the immediate availability of the stable release of Zend Framework 1.10.0. You can download it from our downloads page:
This release includes a ton of new features (more on those below), as well as some huge changes to our documentation.
Our documentation has been slightly re-organized into new sections. Previously, the manual was divided simply into chapters, one per component. Those chapters still exist, but have been moved into an explicit “Reference Guide” section. We have also added a new section entitled, “Learning Zend Framework,” that includes a number of tutorials for using various framework components, including our former “Quick Start” guide. Initially, we’re offering nine tutorials, ranging from first steps to advanced layout and view usage, to search and pagination. These tutorials are now an official part of our documentation, and you can expect improvements, translations, and additions in the versions to come.
To render our documentation, we’ve moved from the venerable xsltproc to PHP.net’s own PhD. This provides us more flexibility in how we render the manual — including the ability to render it differently for packaging versus the online manual. Additionally, it brings the rendering time down from over an hour to just minutes — which will make the release process faster and smoother. Please join me in thanking Shahar Evron and Hannes Magnusson for assisting in our transition to this fantastic tool.
Another big change is that we are now providing versioned documentation on the website. For each minor revision of Zend Framework (1.10, 1.9, 1.8, etc), you can now find both the manual as well as the API documentation. This should assist users who are building off of older versions of ZF.
Finally, our download page has a new design, aimed to be simpler and more visually appealing.
We have a few more site updates in store that we’ll be rolling out over the next few weeks; stay tuned for further announcements!
Below is a list of new features included in the 1.10.0 stable release:
- Zend_Barcode, contributed by Mickael Perraud
- Zend_Cache_Backend_Static, contributed by Pádraic Brady
- Zend_Cache_Manager, contributed by Pádraic Brady
- Zend_Exception – previous exception support, contributed by Marc Bennewitz
- Zend_Feed_Pubsubhubbub, contributed by Pádraic Brady
- Zend_Feed_Writer, contributed by Pádraic Brady
- Zend_Filter_Boolean, contributed by Thomas Weidner
- Zend_Filter_Compress/Decompress, contributed by Thomas Weidner
- Zend_Filter_Null, contributed by Thomas Weidner
- Zend_Log::factory(), contributed by Mark van der Velden and Martin Roest (of ibuildings)
- Zend_Log_Writer_ZendMonitor, contributed by Matthew Weier O’Phinney
- Zend_Markup, contributed by Pieter Kokx
- Zend_Oauth, contributed by Pádraic Brady
- Zend_Serializer, contributed by Marc Bennewitz
- Zend_Service_DeveloperGarden, contributed by Marco Kaiser
- Zend_Service_LiveDocx, contributed by Jonathan Marron
- Zend_Service_WindowsAzure, contributed by Maarten Balliauw
- Zend_Validate_Barcode, contributed by Thomas Weidner
- Zend_Validate_Callback, contributed by Thomas Weidner
- Zend_Validate_CreditCard, contributed by Thomas Weidner
- Zend_Validate_PostCode, contributed by Thomas Weidner
- Zend_Pdf parsing speed has been improved by around 40%
- Additions to Zend_Application resources, including Cachemanager, Dojo, Jquery, Layout, Log, Mail, and Multidb (contributed primarily by Dolf Schimmel)
- Refactoring of Zend_Loader::loadClass() to conform to the PHP Framework Interop Group reference implementation, which allows for autoloading PHP 5.3 namespaced code
- Updated Dojo version to 1.4
Zend_Tool was refactored to eliminate issues and bottlenecks, as well as to add a number of new features:
- New CLI runner with home directory and configuration support
- New providers for Model generation, DbAdapter setup, Layouts and Form Generation
- Default project structure comes with logging support in the ErrorController
As you will note from the above, this release was very much community-driven. In addition to these direct contributions of features, we also received a ton of bugfixes during our community bug hunt days the last few months, tons of translations of our manual (particularly due to the addition of tutorials!), and had countless individuals step forward to report website issues (that we hopefully resolved with this release). Please join me in extending a huge thank you to the Zend Framework community!
Logging in Users using Doctrine and Zend_Auth
Jon Lebensold publishes the second part of his series on using Doctrine in combination with Zend_Auth & Zend_Auth_Adaptor; Here’s the second part of my Doctrine / Zend_Auth example. In 15 minutes, we create a logout, login and protected area that’s reliant on the ZC_Auth_Adapter adapter we created in last week’s video. Notice how there’s no code in the IndexController exposing the authentication implementation,
Grab a copy of the project or browse the repository.
Check it out here; Zendcasts.
Writing a Zend_Auth_Adapter with Doctrine
Jon Lebensold publishes another installment of his popular screen cast series, he writes; I’ve been using Doctrine a lot in my own work, and recently found myself itching to have tighter integration between Zend and Doctrine when it comes to user logins. Luckily, Zend provides a very simple interface with regards to Zend_Auth. This way, it’s easy to decouple your persistence layer (in my case Doctrine) from the authentication layer. I’ve borrowed from Palo Verede’s wonderful article on Doctrine and Zend_Auth and I invite you to check his blog out.
Grab a copy of the project or browse the repository.
Look at the video and comment here; Zendcasts.
Zend Framework Documentation Now Version Specific
This is VERY good news!!!
The Zend Framework has updated their documentation site with a very handy feature for those that may not be working with the latest version of the framework – the ability to select a version of the framework to view the documentation for.
As of the time of this post, they have versions 1.10 back through the original 1.0 of the documentation as well as having them in six different languages. The site’s search can also be limited to a certain version as well, making it super simple to find just what you’re looking for.
Check out their updated documentation site to see these new features in action.
via Community News.
Zend_Image_Deepzoom by Nicolas Fabre
Nicolas Fabre asks for help in reviewing his new component proposal:
Deep Zoom is an implementation of the Seadragon technology for use in Microsoft Silverlight or Seadragon viewing library. It allows users to pan around and zoom in a large, high resolution image or a large collection of images. It reduces the time required for initial load by downloading only the region being viewed and/or only at the resolution it is displayed at. Subsequent regions are downloaded as the user pans to (or zooms into them); animations are used to hide any jerkiness in the transition.
read more Zend_Image_Deepzoom – Nicolas Fabre – Zend Framework Wiki.
Zend_Service_Prowl – Ready for review!
Chris Thomas writes; I’ve created a component proposal. It is ready for review.
Please check it out.
Your comments are welcomed.
Zend_Service_Prowl – Christopher Thomas – Zend Framework Wiki.
Zend_Service_Prowl is a simple component that implements the Prowl API. Prowl is a service that allows users to send push notifications to the iPhone or iPod.
Test Results on Memory Usage of Zend Framework and Doctrine with APC
A few interesting observations made by rvdavid; After investigating a recommendation to use Doctrine by a fellow blogger, Brian at Real of Zod, I have decided to run with Doctrine as my Domain Model in Zend Framework projects. The thing is, if I’m going to commit to this, I need to know that applications I build in the future with the Zend Framework while using Doctrine as an integral part of the Model layer will not take performance hits from things like memory usage.
With Doctrine doing a _lot_ of magic, I thought that this would be something that I wanted to see for myself.
4MB Memory to execute a simple Query?!?! Ffffff#$#!!!!
A quick google search took me to a Question posted on StackOverflow about Doctrine Memory Usage. The concerned OP was asking if he had a server misconfiguration or if this was normal for Doctrine to be using so much memory for a simple query. He posted a 4MB difference in Peak Memory Usage between the start of the request before the Doctrine Query was executed and after the Doctrine Query was executed. After reading that, I was a little nervous.
Use Opcode Caching to reduce Memory Usage.
10 X Zend Amf Performance enhancements — please test!
Wade Arnold comes with some very good news for us that use Zend_Amf, he writes; Mark Reidenbach from everytruckjob.com has submitted a awesome patch for Zend Amf that creates a huge performance increase. Thanks so much Mark! I have also added a reference check optimization that uses SPL_object_hash to quickly see if an object has been seen before or not. Overall you should see a big performance increase. The test case I used was the James Ward’s census data from my ZendCon talk which consists of random people objects ranging from 1 – 100 duplicates totaling 5k total rows. Xdebug profiling analyzed by KCacheGrind showed roughly a 10X increase in performance!
The question is did all of these changes introduce any bugs? I have not been able to find anything and all of the tests pass. However with such a major change I would really appreciate you downloading the attached file and overwriting Zend/Amf/* with it’s contents. Please report any issues in the comments here or better yet on the actual bug ZF-7493 If all goes well we will try and get this into the 1.10 release.
via 10X Zend Amf Performance enhancements — please test! | Wade Arnold.
How to make POEdit detect source strings in Zend Framework
You will notice that once you have started translating an application using poedit it’s quite a smooth process, what hampers the experience a little bit is the mutitude of ways you can write code in Zend Framework, this is great in every way for developers, but requires a bit of thinking when you need to also translate all the UI strings.
So how do we make poedit detect the strings while making our code pretty?
(And guys PLEASE comment on this article with your own hints, tips & quirks!)
For example;
This is a simple login form using Zend_Form;
Zend_Form is completely Zend_Translate i18n compatable, and will read in all strings from your translation sources without the use of specific $this->translate() calls, which makes the code ALOT prettier, see below;
class Form_Login extends Zend_Form {
public function init() {
$this->setAttrib('id', 'LoginForm');
$this->addElement('text', 'username', array(
'label' => $this->getView()->translate('Username'),
'description' => $this->getView()->translate('Please enter valid username'),
));
$this->addElement('password', 'password', array(
'label' => $this->getView()->translate('Password'),
'description' => $this->getView()->translate('Please enter valid password'),
));
$this->addElement('submit', 'submit', array(
'label' => $this->getView()->translate('Login'),
));
}
}
Is the same thing as; but a LOT shorter and cleaner!
class Form_Login extends Zend_Form {
public function init() {
$this->setAttrib('id', 'LoginForm');
$this->addElement('text', 'username', array(
'label' => _('Username'),
'description' => _('Please enter valid username'),
));
$this->addElement('password', 'password', array(
'label' => _('Password'),
'description' => _('Please enter valid password'),
));
$this->addElement('submit', 'submit', array(
'label' => _('Login'),
));
}
}
Both are caught by the poedit keywords scanner that looks for translate() as well as the translate helper shotcode _().
Some notes (And I’ll keep this section updated while I find more tips & hints and quirks!)
But! It always seem to be a But in there;
These two are NOT the same!
translate("Welcome %s, your last login was %s",$this->user['name'],$this->user['active']); ?>
user['name'],$this->user['active']); ?>
The second one explodes with; “Warning: _() expects exactly 1 parameter, 3 given”
That tells us that;
or even (if you have short tag mode on;
= _('Logout'); ?>
should be ok to use. except that it’s not producing the translated output in an view.phtml or layout.phtml. so we are forced to use;
translate('Logout'); ?>