views:

169

answers:

6

I've recently begun building version 2 of my year-old custom MVC framework. It's worked great for me on a number of projects, but I definitely see room for improvement. It's missing some major functionality like ACL, form validation, and caching. As much as I'd love to build those parts myself, I know that realistically it's not a smart decision. So, I've started looking at Zend Framework 1.9. I really like how its component library is loosely coupled. However, from looking at different tutorials, it seems very verbose. I've seen some sample applications that I could duplicate using less code with my own framework. As such, I'd like to "redefine" much of it to make it more RAD friendly. So before I invest a lot of time digging into the framework, I was hoping someone could shine some light on this subject for me. I'm a coder at heart, and have no problem spending hours upon hours tweaking and customizing something if it has a solid foundation (which I hope ZF has).

I should note that I'm very happy to see that Doctrine can be integrated with ZF.

If ZF isn't easily extendable, what other frameworks are (that also have ACL, form validation, caching)? I've been looking at Symfony, but the whole Configuration over Convention thing bothers me a lot.

Thanks in advance for any input.

Edit
To answer tharkun's question, what I mean by 'easily extendable' is that I can roll my own classes (that may or may not extend ZF classes) and package them in the framework so that I can easily build a foundation of code for my own projects.

+5  A: 

Among the popular PHP frameworks ZF is surely the one which is most readily extended, especially because of the loose coupling.

Thanks for the clarifications.

What you describe is exactly what ZF is good at but I'd say it is also exactly what OOP is good at so I would regard an OO framework that doesn't support this a case for the rubbish bin.

Anyways. With ZF it's normally done in a way that you keep your own library in a parallel structure to the ZF folder structure. You can use the ZF autoloader and register your library folder with the autoloader by adding it to the namespace. Example:

//this will be the only require needed for your whole application
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Mylibrary_');

In Mylibrary you should then follow ZF naming conventions. Say you want to extend the Zend_Db_Table_Abstract Class. This class is located logically under Zend/Db/Table/Abstract.php. Your library should now replicate that structure: Mylibrary/Db/Table/Abstract.php. And you would name your class in that file:

class Myproject_Db_Table_Abstract extends Zend_Db_Table_Abstract
{
    /*
    now you're ready to extend and override as much as you like.
    and as a bonus you'll not even hav to include your library files 
    since your library is registered with the loader
    */
}

Did you have anything else in mind when asking this question?

tharkun
A: 

Hi, it is nearly no problem to extend the Zend Framework.

It is an common practice to setup some kind of "myExtenions" wich are co existing with the Zend Framework Library. As example you can take a look on :

Zym Zend Framework Extension

ArneRie
what do you mean by 'nearly'?
tharkun
+1  A: 

Personally Zend FW is my favorite. It kicks ass. Period. That said though, you have to be a coder at heart to be able to appreciate it. It can get quite abstract.

To answer your question; Zend FW is very extendable, everything - really everything - can be extended. Class naming convention is; class Zend_This_IsAn_Example is found in /library/Zend/This/IsAn/Example.php which you would extend as Whatever_This_IsAn_Example which you would put in /library/Whatever/This/IsAn/Example.php It also has autoloading that you can enable, so you won't have to require_once classfiles anymore.

mvc structure;

/application /application/controllers /application/etc /application/models /application/views /library /library/Zend /library/Custom /public

Check out http://framework.zend.com/manual/en/introduction.html and http://framework.zend.com/docs/quickstart

Maurice
A: 

The main point is that you can easily code to interface. Are you not happy with Zend_Acl_Resource implementation? Make your own resource class implementing Zend_Acl_Resource_Interface :)

Tomáš Fejfar
you are not limited to extending abstract classes... ZF is BIG and it's that way because it hase countless extension points.
Tomáš Fejfar
+1  A: 

It's not perfect - There has been a tendency to use static members and concrete class dependencies in ZF - but some of these have been ironed out in later versions of the framework. I'd say that compared with other similar frameworks, ZF is doing well. In fact the loose coupling is probably the biggest selling point of the framework.

troelskn
+1  A: 

I have developed my own framework by extending ZF. And I can tell you that it can be easily done. You can use what you want, and replace what you dont want quite easily. Full ZF follows OOP to the core. They use best practices everywhere. I have learned a lot by observing its code.

Personally I think ZF is the best php framework I have ever seen.

Krishna Kant Sharma