Symfony 2 interview questions and Answers

Last updated on Mar 15, 2022
  • Share
Symfony 2 interview questions

Most Frequently Asked Symfony 2 interview questions

Here in this article, we will be listing frequently asked Symfony 2 interview questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q1. What is Symfony 2 and explain its advantages?
Answer

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.

Q2. Explain the innovations in Symfony2?
Answer
  • 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
Q3. Please write the steps to install Symfony2 using composer?
Answer

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

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

Q4. How to create Controllers in Symfony2?
Answer

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

Example

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

class YourControllerName extends Controller
{
}

 

Q5. How to get current route name in Symfony?
Answer

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

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

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

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

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

Reviewed and verified by Umesh Singh
Umesh Singh

My name is Umesh Singh having 11+ experience in Node.JS, React JS, Angular JS, Next JS, PHP, Laravel, WordPress, MySQL, Oracle, JavaScript, HTML and CSS etc. I have worked on around 30+ projects. I lo...