Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize Zend_Tool output?

I'd like to use Zend_Tool (ZF 1.9) with my project, but I would like to be able to customize the default output of new files. For example, all Controllers should have a specific header pre-pended to the output with phpdoc markup and licensing information to avoid me having to add this as an extra step.

Also, for this particular project (but not all other projects), I need the controllers to extend something other than the default Zend controller as I have extended that for some specific functionality.

The documentation alludes to the ability to do these things, but it does not make it very clear.

From what I can tell I can set up a ~/.zf directory (on ***nix based systems) and include custom providers there. However, this will be machine-wide as opposed to limited to single project scope. Also, while this will add new providers it does not (seemingly) allow me to customize the functionality of existing providers.

Any help here would be greatly appreciated!

like image 921
Jason Avatar asked Aug 09 '09 20:08

Jason


1 Answers

Essentially what Jacob was getting at: what you're talking seems like simple class extending. There's a really simple slideshow introduction to extending Zend Framework here:

http://www.slideshare.net/PHPBelgium/extending-zend-framework-presentation

There are also lots of other resources available online for extending Zend Framework. You can create separate source trees for your different projects, and functionality common to various projects can be added to abstract classes that are in common folders. Something like this isn't common, but I've found it works in those kinds of situations:

class My_Component_HelloProvider extends My_Common_Component_HelloProvider
{
    public function say()
    {
        echo 'Hello from my provider!';
    }

    // public function do() is inherited

}

class My_Common_Component_HelloProvider
    implements Zend_Tool_Framework_Provider_Interface
{
    public function do()
    {
        // do something
    }
}

Let me know if this is different from what you're trying to do, but there's no reason you can't build multiple applcation extensions from a single instance of ZF.

like image 119
angrychimp Avatar answered Nov 18 '22 19:11

angrychimp