Symfony Interview Questions and Answers

Symfony is an open-source PHP web application framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Symfony is sponsored by Sensio Labs. It was developed by Fabien Potencier in 2005. The Symfony PHP framework comes with a very large and active community. This framework has become very popular, mainly due to the vast number of reusable PHP components. These components are not limited to the framework itself but can be found throughout the PHP community, such as Drupal, WordPress, phpBB, and Laravel.

Symfony 2 was released in 2011, but it must not be confused with Symfony 1, which was a totally different framework with different underlying principles. Symfony 2 is created by Fabien Potencier. Symfony is aimed at building robust applications in an enterprise context, and aims to give developers full control over the configuration: from the directory structure to the foreign libraries, almost everything can be customized. To match enterprise development guidelines, Symfony is bundled with additional tools to help developers test, debug and document projects.

Symfony was published as free software on October 18, 2005 and released under the MIT license. Current is Symfony v4.0.1 / 4 November 2017.

Symfony is a modern, enterprise-level PHP web application framework which utilizes the latest web technologies. It enables web building in PHP and some of the finest applications to have been created on Symfony include Drupal, phpBB and eZ Publish. But it’s also much more than that. Proponents of Symfony see it, not only as a technological tool, but also as a philosophy and even as a basis for community. Symfony sets itself apart with its strong architecture, large community, developer tools, and limitless extensibility.

The Symfony framework is adaptable, scales easily, and is full-featured, reports Laeeq of Web Revisions. Symfony is used by many large companies (like the BBC or CBS), by many large websites .some Open-Source projects are also powered by Symfony (CMSes like Drupal or eZpublish, libraries like PHPUnit or Doctrine, products like phpBB or shopware, and even frameworks like PPI or Laravel). This brings a lot of interoperability between all these solutions. Symfony is not a framework but a project. Depending on your needs, you can choose to use some of the Symfony Components, the Silex micro-framework, or the full-stack framework. Symfony has plenty of reusable PHP components that can be used like Security, Templating, Translation, Validator, Form Config and more.

A controller is a PHP function you create that reads information from the Request object and creates and returns a Response object. The response could be an HTML page, JSON, XML, a file download, a redirect, a 404 error or anything else you can dream up. The controller executes whatever arbitrary logic your application needs to render the content of a page.

Symfony bundle are very similar to plugins or packages in other frameworks or CMS. In Symfony, everything is a bundle from core framework components to code you write. The bundle gives the flexibility to use pre-built features packaged in third-party bundles or to create and distribute your own bundles.

Symfony2 is a full-stack web framework written in PHP. Symfony2 is a reusable set of standalone, decoupled, and cohesive PHP components that solve common web development problems. It is also MVC framework. Symfony2 introduced truly unique HTTP and HTTP cache handling by being an HTTP-centric request/response framework, and also by allowing full use of advance features like ESI for separating the different parts of your page/application. Symfony2 is powered out of the box by a fast PHP-built Symfony reverse proxy, and for mid- to large-installations a seamless upgrade to Varnish provides a 10-20x speedup, and a far more robust cache handling.

Twig templates are meant to be simple and won’t process PHP tags. This is by design: the Twig template system is meant to express presentation, not program logic. Twig is fast because each template is compiled to a native PHP class and cached. The more you use Twig, the more you’ll appreciate and benefit from this distinction. And of course, you’ll be loved by web designers everywhere.

A route is a map from a URL path to a controller. Suppose you want one route that matches /blog exactly and another more dynamic route that can match any URL like /blog/my-post or /blog/all-about-symfony: