Thursday, 1 June 2017

Symfony2 Interview Questions and Answers

Symfony2 Interview Questions and Answers

Question: What is Symfony?
Symfony is a PHP framework and a set of reusable components/libraries.

Question: What is current Stable version of Symfony?
Version: 3.2.7, Dated: 5 April 2017

Question: What is offical website URL of Symfony?

Question: What is offical Github URL of Symfony?

Question: What are the benefits of Symfony?
  1. Low performance overhead
  2. Robust Applications
  3. Speed up the creation and maintenance
  4. Unlimited flexibility

Question: What are the innovations in Symfony2?
  1. Symfony2 uses the Dependency Injection pattern.
  2. Symfony2 is packaged as Distributions
  3. Everything is a Bundle in Symfony2.
  4. Symfony2 eases the debugging of your application.
  5. Symfony takes Security very seriously

Question: How to install Symfony2?
Create a folder and Go to in that folder using cd command.
Execute Following command
php -r "readfile('');" > symfony

Question: How to create controller in Symfony2?
File Location: src/AppBundle/Controller/UserController.php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class UserController extends Controller


Question: How to create Action of controller in Symfony2?
Add following code inside UserController.php
    public function indexAction()
        return $this->render('user/index.html.twig', [ ]);

Question: What is format of view file?
File Location: app/Resources/views/user/index.html.twig
{% extends 'base.html.twig' %}

{% block body %}
Welcome to Symfony2</h1>
{# ... #}
{% endblock %}

Question: How to get current route in Symfony?
$request = $this->container->get('request');
$currentRouteName = $request->get('_route');

Question: How to get current route in Symfony?
$request = $this->container->get('request');
$currentRouteName = $request->get('_route');

Question: How to get the request parameters in symfony2?
$request = $this->container->get('request');

Question: How to var_dump variables in twig templates??
{{ dump(user) }};

No comments :

Post a Comment