Symfony vs cakephp

What is the conceptual difference between symfony and cakephp?

+51
php cakephp symfony1
Aug 6 '09 at 23:24
source share
9 answers

Just to balance this thread, this is why I like symfony:

  • uses PHP5
  • he is launching some really big sites like Yahoo! Answers, tasty and daily movements .
  • good documentation. The jobeet tutorial on the website is awesome. goes through all the functions, and after you finish, you feel that you can create something.
  • is very modular ; many symfony components work independently.
  • allows you to choose Propel or Doctrine as your ORM. The doctrine is really great and easy to use.
  • You can define your models using YAML or PHP, it is up to you. Some people don't like configuration files, and you can really limit their use if you want to avoid YAML.
  • The updated symfony cli (version 1.2) is awesome. I agree with abales, before this version it was a bit disgusting, but now it is very well documented and follows a predictable format.
  • There are many, and I mean a lot, similarities with ruby ​​on rails, except that, of course, PHP is not as pretty or flexible as Ruby (!). But, if you talk to the cake developer, they will probably say the opposite :)
  • the symfony admin generator , which is a step from CRUD (which also exists in symfony), is a huge time saver. Using your data model, it will create custom admin interfaces complete with a list (index), creating and editing pages. This is not like the base pile where it generates the source, and you go in and change it ... In fact, you can determine what each field looks like, what fields you want to include, what additional actions you can perform for each object, etc. .

Conceptually, I would say that the difference is this:

  • CakePHP has a lesser learning curve. If you've never used the MVC framework, Cake will be easier to pick up and run in a short amount of time.
  • Symfony feels a bit "big", not to mention that it is slow, but there is a lot of code that will allow you to do a lot of really advanced things when you need to.

The best advice I can give is to quickly try to create my own simple data model in both, and experiment with some basic interfaces, and just see what works best for your own coding style. I think that both structures have very active and passionate user communities, and you will not regret your decision in any case.

+67
Aug 07 '09 at 20:23
source share
  • CakePHP's philosophy is similar to Ruby on Rails.
  • CakePHP is best for medium sized projects.
  • CakePHP learns faster.
  • CakePHP is lighter than symfony.
  • CakePHP Database Interaction uses CRUD.
  • CakePHP uses the PHPUnit test system.
  • Interesting in CakePHP Bake and scaffolding.



  • Symfony's philosophy is that every version is different.
  • Symfony is slower.
  • Symfony is best for large projects.
  • Interacting with Symfony Databases uses Doctrine.
  • Symfony uses the PHPUnit test system.
  • Interesting in Symfony Bundles and templates.
+26
Jan 24 2018-12-12T00:
source share

The big difference is how the models are created: CakePHP models are written in PHP, and Symphony models are written in YAML and run on Propel. CakePHP's approach is more like an ActiveRecord ROR (although this is not really an AR implementation). CakePHP is generally more rails-esque.

The CakePHP documentation and tools, in my opinion, have a wider target audience, and the syntax and helpers are simpler, but you still don’t have the opportunity to use PHP5 as your exclusive goal (it doesn’t actually exist for automatic loading). In general, I prefer CakePHP's approach because it conforms to an established standard, and I welcome its organization. I would also recommend Kohana for him the kindness of PHP5.

There's another stack overflow message on this, although its focus is slightly different.


Edit: I returned Symfony to find the reasons why I said no and came up with them - your opinions and mileage may vary:

CakePHP also offers dead simple forests and easy-to-understand CLI tools. The Symphony CLI syntax is a little awkward for me, and the "CRUD" in Symfony is simply not the same. Combine this with the symfony (awkard) action syntax and drop a poorly designed (and difficult to understand) website to symfony, and also prefer third-party paid documentation (books on Amazon) and you have more ticks in the cons column.

+22
Aug 6 '09 at 23:32
source share

Some of the claims regarding CakePHP and the limitations above are simply incorrect. Request is possible. You just have to know how to do this. The "automatic" CakePHP SUPER is good, so you can hit the ground using FAST. This is a FAST FAST development framework (hence why it is so heavily modeled after RoR, which obviously had great success and buzz). There is a better behavior to get the data received in different ways and to make some of these more complex queries with a few short method calls and array parameters.

However. As far as I can tell, no other structure has as many “automatic” methods and classes. The cake takes on the most common tasks and provides an easy way to do this. If you are really smart, you will do most of your coding at the model level and use the app_model and app_controller file and have an extremely efficient application.

The console is great and always expanding. The community is truly amazing and there are many contributions that will help you speed things up. You can literally architect and then move the “pieces” into place to quickly build the application, because most of what you need is available. You do not understand this with any other structure. You should spend more time coding.

Finally. While the documentation was lagging, now it is much better, and while Cake also received some severe reviews during the absence of documentation and the version 1.1 period ... It was TOTAL good, just badly missed. With 1.2 and now Cake2 and Cake3 are on the horizon ... you will see many opinions.

I have been using CakePHP since 1.1. I firmly believe in that. I used it for huge corporate sites. It gets millions and millions of hits per day ... We are out of the realm of things like WordPress and Drupal for solutions. When you get to this level for a site like CMS, I am very glad that it has CakePHP. Similarly, Symfony and CodeIgniter will help you scale. I can not say anything bad about any of these structures. I can only say that you spend less time coding and find a larger community (and a super friendly IRC channel) with CakePHP.

+14
Aug 18 '09 at 1:21
source share

I review and document some of my answers to the above comments about CakePHP, and some of them (in some cases correctly) accept errors.

Large websites run using CakePHP, some of which are Mozilla Addons, Scratch by MIT, and Hot Scripts. At the bottom of the CakePHP website is a large list ( http://cakephp.org ). Regardless, any good developer should be able to create a scalable website using a framework if the structure is not completely dumb (CakePHP is not too dumb: D).

It is true that there is not a single very good (free) CakePHP tutorial that goes through all the functions of the framework, but the documentation is very well laid out and described in detail. Anything that is not clear can be clarified through the Google group and the IRC, and we welcome any changes or corrections to the documentation. Documentation is not just the main problem with the developers, as many things are application-specific, and people come up with interesting tips and tricks, and therefore everyone is invited to contribute (not just a comment!). Of course, everything is moderated, so most of the cracks / spam is not added.

The code is modular because you can add new code that surpasses the core features. Most of the code is just PHP classes. It is true that writing such functionality can be a burden, and I have not tried using alternative classes as fillins. Yes, it does not handle other ORMs, so you are stuck with the default setting, but this should be fixed in Cake3, which will be able to mix and map any other PHP classes as desired (including Propel and Doctrine support).

The CLI is very good and easy to extend to support applications. One example is that I recently developed a shell plugin that would automatically install any other CakePHP plugin that I indexed from github. It took about 5 hours to build something extremely comfortable and flexible. I am sure that such functionality exists for Symfony, and it exists for RoR :)

Regarding Rails-like, it is, and it is not. Many things are similar, in any case, they are MVC structures, and CakePHP is for the "Agreement against configuration" approach. PHP4 supports mucks with a stronger syntax that Symfony undoubtedly has because of only PHP5 support, but it is still extremely useful and intuitive. The frame does not provide EVERY Rails function out of the box, as it is not a direct clone. CakePHP is a structure, not a library (hi Zend), so it won’t provide everything out of the box.

The generation of submissions, I agree, is a bit awkward in CakePHP. It is greatly improved in CakePHP 1.3 and 2.0. It will support custom templates for each model, view, and controller (as opposed to the view type as it is now). In addition, there is a set of shell tasks on github by a user walking on neilcrookes that automatically bakes only certain types of views (including only admin views), which can be used in combination with custom templates to get exactly what you want. CSS style also helps :), but it is definitely something that can be improved.

CakePHP uses many different Model :: find parameters in it, although in some cases it may be useful to use raw SQL queries. The Model :: find () method is very flexible and did not fail me to create complex finds. I believe that this is due to the comfort of working with ORM, which inevitably takes time.

Validation of the form should logically be at the model level, since any action related to the database is performed there. You can specify alternative validation in a specific view, in my opinion, or on swap checks (there is a behavior for this, but without it it would not be easy).

Multidimensional arrays are a bit stupid, but you still have multidimensional objects. PHP4 had a broken object model, so CakePHP does not use objects. This will be fixed in a future version of CakePHP (as I mentioned above in a previous comment), but in some cases it is useful to have a framework that supports PHP4. Again, YMMV and I agree that full PHP5 will be a great addition to application speed and development.

Databases can be changed as desired. CakePHP does not allow the use of functionality that is inherent in only one type of database (hence the rejected ENUM support, only in MySQL), so ORM is always supported and can always create reliable queries. You can have several databases in the application, one for each model, if you want, and you can change them as you wish or even not use the database at all for a specific model. Thus, no, it is not tied to a specific database.

In the end, your choice is your own, and I sincerely suggest looking at both and reading the documentation, checking groups, IRC channels, blogs and any forums for both and see which structure suits your development style., Reader be careful, I CakePHP developer, so my post has a bias.

+12
Aug 13 '09 at 9:22
source share

In addition to the existing answers, you should try both if possible. I use both quite a lot, and for some time I prefer symfony.

but I’m sure that it’s not because this or that is better, but because symfony seems to be suitable for my mind, which works better, it’s closer to what I do when I write software out of the frame, so it feels more intuitive, I expect others to find their own mind that matches the paradigm of another structure.

Having said that, I think cakephp objects are a weakness due to the use of arrays rather than objects. (This is what periodically develops into an internal hatred in me when I need to do something that complicates ...) They can do the same, but return objects, not arrays, to represent data, and I think that most of the problems that I have will disappear - you can add additional functions to the data objects to achieve what I want to do, instead of writing functions to an existing model class and passing them an array.

+9
Aug 08 '09 at 8:55
source share

CakePHP model layer is a mess. Try to do simple things, such as many-to-many relationships between a Category object and an Object, and then get all the elements in a category that have a specific set of properties.

how

SELECT items.* FROM items, categories, item_categories WHERE item.available=1 AND category.id=1 AND item_categories.category_id = category.id 

Something so trivial is impossible in a single statement in the cake using the model's find () method.

There is also no way in the core API to add one many-to-many relationship, like in one element, in the item_category table above. There are several solutions on the Internet, including the behavior that someone sent to the bakery ( http://bakery.cakephp.org/articles/view/add-delete-habtm-behavior ), but it’s just that any good ORM framework, Propel, Torque (Java), Hibernate (Java), SQLObject (Python), SQLAlchemy (Python) right out of the box. Basically, you will have to write a lot of PHP code to add these missing functions or use raw SQL queries, but the main purpose of the structure is to avoid doing these things so that you can focus on the application that you won’t win much with CakePHP .

There are many other problems, and all of them are really related to the model level, including form validation tied to the model layer, the need to deal with random multidimensional arrays, forcing the use of raw sql and linking your application to a specific database.

I would say using symfony. It may take several days to study, but it's worth it. I was going to use CakePHP for the project I am working on, after I went over to too many of these types of problems, I switched to symfony and it was a smooth swim.

+6
Aug 13 '09 at 5:51
source share

Another difference: Symfony is divided into 3 environments: development, production and testing - CakePHP can't! Easy to develop and test the product at the same time.

+6
Dec 6 2018-10-06
source share

Cake 2.0 perfectly loads most of the classes you need, while in Symfony 2 I found that each class should have numerous import data at the top of the script. Trying to remember all of these imports is almost impossible, so you always need some background information.

, eg. Symfony 2 Controller Code ...

 namespace Acme\HelloBundle\Controller; use Symfony\Component\HttpFoundation\Response; // bunch of other imports accumulate here... class HelloController { ... 

Argh, yuck. Although this may be a good OO technique for purists, it lengthens development time (goodbye RAD). At least with Cake, I can quickly write most of the simple things out of memory.

+4
Feb 28 '12 at 22:20
source share



All Articles