What are the advantages and disadvantages of Symfony2?

Source: Internet
Author: User
Welcome to the discussion. Welcome to the discussion. Reply content: improves the abstraction level of the code. Compared with the simple PHP language that directly exposes underlying concepts, Symfony provides a set of concepts and tools to solve specific engineering problems, helping the majority of Coder reduce repetitive work. Abstraction means that complex concepts and processes can be expressed with more concise things.
Symfony has been written for more than a year. for me, the advantage is that I understand "there are various ways to concise code" and "many advantages of concise code". and "What is Concise?"

Symfony introduction:
  • Routing: the hostname can be restricted, which allows websites with a large number of public functions to share a set of code. URI recognition supports Reg detection, allowing URLs to be defined as desired; prefix, import, easy to modularize.
  • Twig Template: This is my favorite component. It provides a set of syntax that is different from php, but is very suitable for processing complex website structures and page structures. Extension is very convenient and powerful. general operations can be well expressed through extension. for example, if a module of the page needs to be cached to redis, write a ViewExtension, you can use a method in the template to cache specific modules, which is very convenient and easy to manage code.
  • Composer package management: makes code dependencies clear. Third parties now have many good bundle, such as abstract redis snc/redis-bundle, liip/imagine-bundle for image processing, and hwi/oauth-bundle for third-party login. As your project matures, you can also use composer to manage the Symfony customization.
  • Event, Listener, and Services: very convenient global function processing. What is annoying is that the configuration is very troublesome. I use the yml configuration file. in order to find the correct syntax, I really fell victim to it.
  • Doctrine ORM: one advantage is that you don't have to worry about database details, but you only need to carefully design objects that require persistence. The relationships between objects can be freely designed. you don't have to worry about the process from generating the database structure to generating query statements. Another advantage is that when querying, you can use an object-type query instead of SQL, which is expressed by a string such as dql. Because SQL is a simple string, the control of the entire query logic is difficult to express in code.
  • Form component: Symfony provides the form generation, submission, and verification functions. The component abstracts three things: formType to maintain the value to be saved, formTheme to define the html structure of the form, and validation to provide the data verification function. The disadvantages of this component are also obvious, and the concept is too complicated. if you need to define a field by yourself, you are simply looking for trouble.
  • Performance: Symfony provides an excellent component named profile, which can display the execution time, memory consumption, database query statements, and number of queried rows in a graphical manner, used index. Using this tool to optimize the code can make the website run fast.

Performance is not a problem, and the optimization space is very large, but you should at least read the source code to make it performance better. The high learning cost is also a problem. it is similar to learning vim. it is very nice to be familiar with it. otherwise...

Materials:
  • Symfony2-tag
I have read the symfony2 framework over the past two days. now I have finally understood laravel's design philosophy ~~~ Laravel and symfony are basically identical in terms of architecture and core functions ~~ No one is more powerful ~~
However, laravel has two differences: the first language is beautiful and the second out of box. it is user-centered and tends to be black box. it is like Apple's style, just like Apple's mobile phone;
Symfony2 tends to be a white box, and the architecture is clear and flexible, but complicated and cumbersome ~~ You need to make a lot of wheels on your own. The advantage is that the wheels can be easily debugged, a bit like the windows Enterprise Edition.

Symfony2 is a framework worth learning. if you have been playing laravel for a while and need to have a deeper understanding of the kernel architecture, you can look at symfony2. many core concepts of laravel come from there.

But in some design ideas, symfony does not feel like laravel is running. for example, form, symfony has built a self-righteous and complete form system, and all MVC is packaged. Laravel's forms are flexible, all split, and even gave up the V part ~~ For the first time, common programmers often vomit blood when they see symfony's form system.

There is also annotation, which always seems to be an out-of-the-box approach. it's not formal, and I don't feel its benefits now. maybe it's still useless. I just finished three projects with symfony2.
One of them uses sylius bundle, and has previously used codeignitor, yii, zend, drupal, joomla, and wordpress for dozens of projects. since symfony2 was used, I don't want to go back to the previous framework. of course, drupal8 integrates the symfony2 core bundle and is waiting for quick release. After using symfony2, I found the fun of writing code again. it was simple, fast, and elegant. of course, there was a problem, as one of the above guys said, that it completely abstracted the database, all of them need to contact phpmyadmin, and the database can be automatically synchronized through doctrine. of course, the problem is the performance problem and cannot be optimized in a targeted manner. However, the cache provided by symfony2 allows the website to run quickly. What is more important than performance is the ability to make what you want. performance can be adjusted and optimized slowly.

There is also a disadvantage that is not too great for us: Chinese materials are relatively limited. However, we believe that these seminars will enrich the information. The above projects are basically supported in the English community.
Another problem is that some concepts in it are more difficult to understand than other frameworks, such as events, services, security, and dependency injection, of course, this is also the price Behind the Power. The advantage is strong, but the disadvantage is that it is too powerful...
The original 1.0 performance is not good, it is said that 2.0 performance has improved a lot, you can try. Advantages: java
Disadvantages: the disadvantage of java is that it is too heavy, the learning curve is too steep, the performance is really not high, there are too few Chinese materials, mainly in French, followed by English. In addition, due to the early year, the syntax is relatively old (that is why laravel is good, new year, and many new technologies are used ).
The advantage is that there are enough ready-made components, which are massive and open-source, and the reuse pattern is well-designed and fully functional.
The problem with third-party bundle is that the learning cost of each bundle is not low. Although it is open-source, it is difficult to modify it. In addition, many bundle instances have compatibility problems due to historical reasons.
I am using the sonata components to quickly establish the admin management platform. This part is familiar with and can achieve the ultimate development efficiency in the background, there is no possibility of faster development. The interface that requires performance is processed using another framework phalcon. Advantages:
After learning about this powerful exception, I use sf2.
Disadvantages:
The learning difficulty exists. The three or two projects are actually familiar with common components.

If you want to learn sf2, the Best Practice on the official website must look at it. the built-in implementation method of the framework may not be the Best. for example, I still like to use grunt for front-end construction. AsseticBundle basically does not need to use sf2, I just read his document. if springMvc is used, I can easily understand it. Advantages:

Full stack freamwork, powerfully code-generation tools !! Based on the premise of convention over configuration.
In my own experience, Symfony is convenient, agile, and scalable in project development. it is currently one of the best in PHP Freamwork, coupled with its powerful third-party plug-in library and active communities.

Disadvantages:



Learning Curve. to fully understand the Symfony design, it takes at least one week to study the manual and code.
Performance. symfony1.4 and Doctrine1.2 are used in combination. performance in high concurrency is a problem. although Symfony2 and Doctrine2 have been greatly solved .... but that's another topic .... ===



The best framework of PHP is Symfony, which is not used by many phper users because it lacks the necessary basic knowledge for large-scale web development. for example, many phper users do not know what service, event, and DI are connected.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.