zend-framework versus Kohana versus Symfony [close

2019-01-22 22:48发布

问题:

Which one of this frameworks would you recommend to someone who knows the basics of PHP? What are the advantages and disadvantages?

回答1:

I wouldn't suggest any frameworks to someone who knows just the basics. Instead, I'd suggest to get a firm grip on OOP and the most common Design Patterns first, because that is what you will find in these frameworks. It also doesn't hurt to know your way around the various available PHP libs and extensions.



回答2:

I think frameworks are a double edged sword for beginners. You may be able to do more in less time in many cases but in other cases (not a few) you will make mistakes because you do not understand the complexity of the framework code. I think you should be able to read a framework and understand its architecture if you want to use it.

That said it seems that the real cracks use Symfony. It might become or might already be the best, most versatile, most powerfull framework out there. But it definitely needs a lot of understanding of the principles of programming as well as web techonology and server technology in general.

Also very powerfull and much easier to start with is Zend Framework. It can definitely do much more for you than Kohana.

If you want a lightweight framework, Kohana is a good choice too. It has come a long way the last months and I think it is rapidly establishing itself as the new lightweight favourite.

So all in all, the three frameworks you mentioned are the three top frameworks on the PHP framework market at the moment and you won't make a mistake with any of them.



回答3:

UPDATE: It is now 8 years later and Kohana is no longer maintained. Laravel would be my current recommendation for a relatively simple yet very powerful PHP framework.


Even though ZF is well established and well documented, I would suggest Kohana since it is quite a bit less complex. It is very easy to start tinkering with it by simply downloading or cloning the sample application from github.

Symphony is not for beginners. I disagree that frameworks in general are not for beginners. Starting with a blank file and no framework leaves all of the architectural design up to someone who has no idea what they are doing while starting with a lightweight framework like Kohana gives you a well-organised platform and documentation to hit the ground running. Learning OO without any examples to guide you is very difficult since you don't already know what good OO design looks like.

After downloading/cloning the Kohana sample app, hit the docs and you'll be writing well-designed OO code in no time.



回答4:

For a beginner and using the three examples you gave I would say start with Kohana(or Code Igniter) for these reasons.

  1. It's a lightweight framework which is a good starting point for full PHP development because it serves as a guide in how to organize a project in a language that doesn't have a lot of structure on it's own
  2. Introduces basic MVC concepts.
  3. Has basic features that will be useful in any PHP project e.g. caching, data filtering etc

I would then move on the Zend Framework if you plan or strive to work on larger projects for these reasons:

  1. Kohana documentation is greatly lacking (it's manageable for a beginner because you end up poking around and see what makes a framework tick so that they don't see like this ominous holy code which is a plus; but in a major project with timelines it's annoying)
  2. Kohana enforces certain conventions which is often inconvenient in major projects
  3. Lacks mature features that are useful in "enterprise" development e.g. a decent unit testing system (there is rudimentary phpunit modules to use in Kohana and you can certainly use base PHPUnit but in contrast Zend Framework has extended PHPUnit functionality to better suite it's framework)
  4. Better support. Zend framework has the Zend Company behind it as well as a huge community. This is a huge win for them because it permeates in everything about the framework e.g. configuration is thought out much better in Zend framework,more robust security featues, proper class autoloading based on PEAR namespacing, and it has a plethora of contributed components. Some of these benefits you can shrug of when starting but become invaluable when taking on large projects.

I've not used symfony but from what I can tell that also has some useful features once you get more versed in PHP (better ORM, better scaffolding etc). Synopsis: Kohana is a good start but I'd advise against roosting there if you plan to get into PHP beyond small sites.



回答5:

In your case I would go with (in this order):

  1. Kohana
  2. Zend Framework

Since they are easier to pick up (specially for a beginner) than Symphony.



回答6:

I always wondered why people say that not providing a unit test system is a major drawback in a framework. Well, testing you app is your responsibility and you should use the tools you're most comfortable with. Me, for instance, prefer SimpleTest and are bothered with framework that come bundled with and promote the use of their own testing system. Why learn another unit test system when SimpleTest is more than enough?

Notice that providing a unit test system and unit testing the framework is two completely different things. The framework should be unit tested, period. But for this task, the developers of the framework may use the tool they prefer most. They may even roll their own test framework (it seems that some people never learn and keep reinventing the wheel). However, (IMHO) the framework test should be kept separate from the framework itself. It shouldn't even be included on the framework tarball, but be kept as a separate package that interest only to developers of the framework.

Just my 2c.