Loading…

Symfony 2 interview questions

Last update: 11 Oct 2019, 9 QuestionsAsk Question
A Quick Overview of Symfony2
Symfony 2 interview questions

Best Symfony 2 interview questions And Answers

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.

  • 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

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

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

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
{
}

 

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

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

Symfony supports default template engine is Twig, but ever, you are free to use plain PHP code if you want.
In your created controller you can create your action with the following code.

Example

                                                    

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

Add Review