Symfony 2 interview questions and Answers

By Umesh Singh
Last update: 11 Oct 2019, 9 Questions
Symfony 2 interview questions

Most Frequently Asked Symfony 2 interview questions

1. What is Symfony 2 and explain its advantages?

Symfony2 is embracing high standards. It is centered around HTTP specification and PHP standards. These standards make Symfony2 interoperable with amazing PHP libraries. Using the Dependency Injection (DI) pattern, the framework has a built-in DI Container, which makes it flexible and easy to customize.

2. Explain the innovations in Symfony2?
  • It uses the Dependency Injection pattern.
  • It is packaged as Distributions
  • In Symfony2, Everything is a Bundle.
  • It eases the debugging of your application.
  • It takes Security very seriously
3. Please write the steps to install Symfony2 using composer?

composer create-project symfony/framework-standard-edition ProjectName "2.7.*"

// You Can mention here you particular version that you want to install

4. How to create Controllers in Symfony2?

Controller's file default location is src/AppBundle/Controller Now you can create here your controller with below code.



namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class YourControllerName extends Controller


5. How to get current route name in Symfony?

$requestName = $this->container->get('request');
$currentRoute = $requestName->get('_route');

6. How to get the parameters from URL's in symfony2?

$request = $this->container->get('request');
$parameter1 = $request->query->get('parameter1');

7. Symfony support which template engine? Symfony supports default template engine is Twig, but ever, you are free to use plain PHP code if you want.
9. How to create Controllers's Action in Symfony2? In your created controller you can create your action with the following code.



public function indexAction()
     return $this->render('user/login.html.twig', [ ]);