• Home
  • Blog
  • Symfony2 – Ten Ways in Which it got Better than Symfony1!

Symfony2 – Ten Ways in Which it got Better than Symfony1!

Published: May 7, 2015  |   | 

Symfony2 vs Symfony1
Symfony2 is a full-stack web framework consisting of reusable set of standalone, decoupled and cohesive PHP components. It was a major revolution when compared with Symfony1. Symfony1 was a full-stack framework, a library of cohesive classes written in PHP, offering developers’ the architecture, components and tools for building complex web applications in a faster way. To put in a nutshell, Symfony2 consists of a set of reusable components whereas Symfony1 was a kind of rigid and inflexible framework. This blog throws light on how Symfony2 got better than Symfony1, and walks through the key differences between both of them, providing stable, testable and decoupled code in Symfony2 applications.

Structure of Directories

As compared to Symfony1, there are a few changes here and there in the structure of directories in Symfony2.
  • The app/ Directory: Symfony2 consists of only app inside the app/ directory whereas Symfony1 contained one or more apps. As compared to Symfony1 the app/ directory of Symfony2 doesn’t have PHP code. The directory is to store configuration templates and other resources.
  • The src/ Directory: Symfony2 has bundles in the src/ directory, containing all actual code. The directory is similar to Symfony1’s plugins directory, except that it is more flexible.
  • The web/ Directory: There’s not much change in the web/ directory in Symfony2 except that the images/, css/ and js/ directories are not present.

Console

In Symfony1 the console was in the root directory of your project, known as Symfony. The console in Symfony2 has been renamed from Symfony to console and is now in the app sub-directory.

Autoloading

In Symfony1, autoloading was done by searching the entire project for the availability of PHP files and caching such information in a big array. This array helped Symfony1 to know exactly which file contained each class. But in production environment, you were required to clear the cache, when classes were added or moved. Whereas in Symfony2, autoloading has been made more universal, faster and doesn’t require clearing your cache. The entire process is carried out with the help of a tool known as Composer. The concept behind autoloader is that the name of your class along with the namespace should correspond to the path to the file with that class.

Bundles

In Symfony 2 the concept of plug-ins has been replaced by bundles. These bundles are more powerful and flexible than the plugins. Everything in Symfony2 consists of bundles including the framework and application. Symfony2 allows you to customize the application and connect functionality packed into bundles. You can also distribute the code by placing it into a bundle.

Applications

In Symfony1 it was quite normal to have more than one apps, for example one for the front-end and other one for the back-end. However in Symfony2, you are required to create only a single application. In case you wish to create another application, you require building another project sharing the bundles between them.

Doctrine2

Doctrine does not rely on code generation in Symfony2; you will be required to code your objects yourself. The command can help you to build your first objects, but you need to code your files directly. Your objects are lighter, don’t use any base class and have no access to the ORM. Symfony2 also allows using annotations, which are very powerful and are useful in clearly setting relationships.

The Templating Component

The Templating component inn Symfony2 plays an important role in providing all the tools required to create any kind of template system. It provides a base to load template files and monitors them for changes. It also gives a concrete template engine implementation using PHP along with additional tools for segregating templates into blocks and layouts.

Backward Compatibility

Symfony2 supports Backward Compatibility, allowing developers to upgrade from one minor version of Symfony to the next one. Whenever backward compatibility is not possible in Symfony2, the bug fix or the enhancements is scheduled for the next major version.

Maintenance and Upgradability

Symfony2 takes care of the maintenance and upgradability aspect, ensuring the longevity of your application. Each Symfony minor version is maintained for a fixed period and long-term seamless support is given. There are generally two maintenance periods: Bug fixes & security fixes and Security fixes only.

Documentation

Symfony2 has detailed documentation available with a great getting start guide, helpful for new developers. Other than these, Symfony2 has many performance improvements and supports edge side includes (ESI). Forms have got better in Symfony2 in comparison to Symfony1. The code is cleaner and easier. Doctrine 2.0 is much faster and quicker to use. Symfony2 also has standardized testing framework PHPUnit. All these features, improvements and enhancements have made Symfony2 one of the most robust and sought-out frameworks for building web applications. See why you should choose Symfony2 framework for web application development. Semaphore Software has the efficiency in building powerful and scalable Symfony2 web applications. Our proficient Symfony developers build high-quality customized Symfony2 applications, helping businesses grow faster! Get in touch with us through info@semaphore-software.com to get benefited by our tailored Symfony development services!!