Is Symfony a better choice than Zend for a web dev

2019-03-11 16:15发布

问题:

My team at work is considering to use a framework for developing web sites and applications. Some of the seniors are convinced we should use the Zend Framework because it is easier to pick-and-choose the features so the framework we will be light-weight.

I'm afraid however that they are only looking at the technical advantages that a lightweight framework will have. In my opinion it is better to have a full-stack framework (and I am a proponent of Symfony) because

  1. It will also provide us with a standard way of working without writing new documentation.
  2. If we would like to use new features we would only have to read the documentation to see how it can be used instead of having to build it into our setup of Zend first.

I don't expect all my questions to be answered by everybody but this is what I am looking for in the answer:

  • Do I have a point here?
  • Have you been in a similar situation and how did you handle that?
  • Do you have more arguments that I could use OR could make me reconsider my own opinion?

The context: I work at a small shop with about 10 programmers. We mostly program PHP. We use a really simple inhouse developed framework and ORM library that are practically undocumented and lack anything but the most basic features (no validators, no transactions, no caching, no authentication)

回答1:

And why not both? I have been using symfony since 2006, have been a real Doctrine fan for one year, and for a few months, we've reach many steps on the productivity ladder by integrating Zend components directly onto our symfony applications.

The real strength of symfony lies on the decoupling of everything, and the easy extensibility of the framework. You can replace almost every layer of the whole thing. Just copy/paste the Zend directory in /lib/, and add this singleton in /config/ProjectConfiguration.class.php:

    static public function registerZend()
{
    if (self::$zendLoaded)
    {
        return;
    }

    sfToolkit::addIncludePath(sfConfig::get('sf_lib_dir') . '/vendor', 'back');
    require_once(sfConfig::get('sf_lib_dir') . '/vendor/Zend/Loader.php');

    Zend_Loader::registerAutoload();
    self::$zendLoaded = true;
}

And use freely any Zend component you might like. You might be interested in the new Jobeet tutorial, and especially at the Search part, which uses Zend_Lucene_Search.



回答2:

Symfony is really easy to use and can get a fully functional site with sessions, caching, unit and functional testing, automated deployment and more up and running in a very short amount of time. You only really need to worry about code to access and display your data. Whist it may not be as lightweight as a roll-your-own implementation, the amount of code you have to maintain will be less.

The Propel/Creole ORM works well, has built in validators etc and is set up to be extensible out of the box.

When transitioning an in-house framework over to Symfony I was able to re-use lots of library code simply by putting it in one of the lib directories that Symfony scans at startup.

Although I've not used it, there is a Zend bridge built into Symfony that allows you to use Zend modules if needed.

Hope that helps.



回答3:

I think the ZF documentation and community involvement is better. I also like the naming scheme, coding standard and extensibility of it. ZF also seem to get a lot of new features and improvement to existing classes like an open source project, from many different people working on their own pet projects.

I don't really see how Symfony is an advantage for a group of 10 programmers. Clearly you should be able to relatively fast set up a default configuration for new projects, and have lots of extensibility built on top of and in addition to ZF.



回答4:

How is ZF not "full stack"? It seems to contain every element Symfony does, and then some. Moreover ZF has a "pick your poison" approach, allowing you to use different pieces in different methods. (As an example, we use Zend_Config in lots of different places, just so everyone can expect a reasonably uniform configuration system, even on tiny pieces of code).



回答5:

I'm afraid however that they are only looking at the technical advantages that a lightweight framework will have. In my opinion it is better to have a full-stack framework (and I am a proponent of Symfony) because ...

It depends a lot on the type of application(s) you're building. If you're building a lot of low-complexity, mostly content-driven applications, then Symfony will shine. On the other hand, if your application doesn't fit into the naked-object paradigm of Symfony (For example, if it's complex and not entirely focused on content management), you may find it more of a hurdle, than a help.



回答6:

I have limited experience with either, but a good starting point for setting "standards" for Zend is to follow their tutorials for using the different modules - many of them give sane defaults that work for 99% of the projects out there.

I would say it comes down to what you need it for - Zend for flexibility, Symfony for a quicker start and pre-developed standards if your project has no extraordinary needs.