May 29
2008

Extending Zend_Form for custom forms tip

Posted by PotatoBob in Zend FrameworkPHP

avatar

Many people have created custom forms by extending Zend_Form and overriding __construct like so:

class MyForm extends Zend_Form
{
    public __construct($options = null)
    {
        parent::__construct($options);
        // [...] Form code
    }
}

However, without looking at the api, you'd never see you could do it like this which is slightly cleaner:

class MyForm extends Zend_Form
{
    public init()
    {
        // [...] Form code
    }
}
Feb 16
2008

DIRECTORY_SEPARATOR is not needed!

Posted by PotatoBob in Zend FrameworkPHP

avatar

Overview

One of PHP's misconceptions is that in order to write portable code, the DIRECTORY_SEPARATOR constant is needed for all folder paths. An example of this is in require's.

require_once(MY_PATH . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'my.php');

The alternative

PHP is smart enough to handle all paths that use a forward slash '/' on all platforms (that means windows). Using a forward slash instead of the directory separator constant where possible will make your code more readable. Zend Framework uses this method on all of its require's.

/**
 * @see Zend_Controller_Front
 */
require_once('Zend/Controller/Front.php');

After running a few tests and speaking to several people, it seems that it is perfectly fine to take this alternative. For most code, as long as you are using the forward slash '/' not the windows back slash '\' portability is guaranteed.

Why have a constant? 

The constant is particularly useful because paths given by php use the native system's directory separator. The constant is particularly useful if you need to do some path mangling or exploding etc..

That's all 

While I am just giving out my opinion here as I find that the DIRECTORY_SEPARATOR use can go out of hand, it is up to you to decide. Please provide feedback on what you think ;).

References

  • http://old.alanhogan.com/tips/php/directory-separator-not-necessary
  • http://us2.php.net/manual/en/ref.filesystem.php#73954 
Feb 02
2008

Zend Framework 1.5 PR - Development Moves On!

Posted by PotatoBob in Zend FrameworkPHP

avatar

Whoo!

With the release of Zend Framework 1.5PR, the feel of the framework moving forward starts to come back. Some things to look for in this release are Zend_Form, Zend_Db and Zend_Layout as they play an important role in the framework. This release should be completely backwards compatible for those who wanted to know. (I mean to say that 1.5 should be backwards compatiable with the 1.0.x seriers).

Listed below are some additional features posted by Wil Sinclair :

  • Zend_Auth_Adapter_Ldap
  • Zend_Build/Zend_Console
  • Zend_Controller additional action helpers
    • ContextSwitch and AjaxContext
    • Json
    • AutoComplete
  • Zend_Form
  • Zend_InfoCard
  • Zend_Layout
  • Zend_OpenId
  • Zend_Search_Lucene improvements:
    • wildcard search
    • date range search
    • fuzzy search
    • Lucene 2.1 index file format support
  • Zend_View enhancements:
    • actions
    • partials
    • placeholders
  • Zend_Pdf UTF8 support
  • New Zend_Service consumables (final list TBD)
  • A whole lotta bug fixes and documentation improvements

Note for Naneau : It's been 4 months since you've posted... :(

<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>