Showing posts with label Symfony. Show all posts
Showing posts with label Symfony. Show all posts

Monday, 21 October 2019

Symfony2 Interview Questions and Answers for Beginners

Symfony2 Interview Questions and Answers for Beginners

Question: What is Symfony?
Symfony is a PHP web application framework for MVC applications.


Question: Is Symfony Open Source?
Yes, It is Open Source.


Question: What is current Stable version of Symfony?
Version: 5.0.4, Dated: 31 Jan 2020


Question: What is offical website of Symfony?
symfony.com


Question: What is minimum PHP Version requirement for Symfony?
PHP 7.2.5


Question: What are benefits of Symfony?
  1. Fast development
  2. MVC Pattern
  3. Unlimited flexibility
  4. Expandable
  5. Stable and sustainable
  6. Ease of use.



Question: How to concatenate strings in twig?
{{ 'http://' ~ app.request.host }}



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



Question: How to render a DateTime object in a Twig template?
{{ game.gameDate|date('Y-m-d') }}



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



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



Question: How to get list of all installed packages in composer?
composer global show


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?
http://www.symfony.com



Question: What is offical Github URL of Symfony?
https://github.com/symfony/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('https://symfony.com/installer');" > symfony



Question: How to create controller in Symfony2?
File Location: src/AppBundle/Controller/UserController.php
Format:
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 %}
    <h1>
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');
$name=$request->query->get('name');



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