300+ TOP SYMFONY Interview Questions and Answers

Symfony Interview Questions for freshers experienced :-

1. What is Symfony?
Symfony is an open source, web application framework. It is written in PHP and used to design PHP applications. It was first released on18 October, 2005.

2. What is current Stable version of Symfony?
Current stable version of Symfony is 3.3.2 and was released on 6 June, 2017.

3. What are the benefits of Symfony?
Symfony has various benefits that are listed below:

  • Fast development
  • MVC Pattern
  • Unlimited flexibility
  • Expandable
  • Stable and sustainable
  • Ease of use.

4. Does Symfony use Controller?
Yes, Symfony framework use controller. A controller is a PHP function that is used to handle HTTP request and response.

The response could be in the form of HTML page, an XML document, an image, a redirect, a 404 error etc.

5. What are the innovations in Symfony2?
In Symfony2, some following Innovations are:

Symfony2 uses the Dependency Injection pattern.
Symfony2 is packaged as Distributions
Everything is a Bundle in Symfony2.
Symfony2 eases the debugging of your application.
Symfony takes Security very seriously
6) How can we install Symfony2?
We can install Symfony2 using given following command:

In Windows :

php -r “readfile(‘https://symfony.com/installer’);” > symfony

InLinux and macOS System :

sudo mkdir -p /usr/local/bin

sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony

sudo chmod a+x /usr/local/bin/symfony

7. How can we create controller in Symfony2?
In Symfony, we can create controller by extending AbstractActionController class.

Example

use Zend\Mvc\Controller\AbstractActionController;

use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController {

public function indexAction() {

return new ViewModel();

}

}

8. How can we get the request parameters in symfony2?
In Symfony, we can get the request parameter using following method:

$request = $this->container->get(‘request’);

$name=$request->query->get(‘name’);

9. When Symfony denies the user access?
Symfony denies the user access, when a unauthorized user try to access web application, it throws a 403 HTTP status and error page.

10. In which technology, routing configuration files are written?
Routing configuration files are written in the following technology:

  1. YAML
  2. PHP
  3. XML
SYMFONY Interview Questions
SYMFONY Interview Questions

11. What is the default routing configuration file in Symfony2 application?
Default routing configuration file is: app/config/routing.yml

12. How to create a bundle called AcmeHelloBundle, what command we need to run.
Create a bundle called AcmeHelloBundle and run the following command.

$ php app/console generate:bundle –namespace=Acme/HelloBundle –format=yml

13. How we can create action in Symfony2 controller?
We can create action using following command:

public function indexAction()

{

return $this->render(‘user/index.html.twig’, [ ]);

}

14. How can we get current route in Symfony?
We can get current route in Symfony using following steps:

$request = $this->container->get(‘request’);

$currentRouteName = $request->get(‘_route’);

15. What is an Environment in Symfony?
In Symfony, an environment represents a group of configurations that’s used to run your application. It defines two environments by default:

  • dev (suited for when developing the application locally)
  • prod (optimized for when executing the application on production).

16. What are the Symfony framework applications?
There are various Symfony framework applications:

  1. Drupal 8
  2. Thelia
  3. Dailymotion

17. What are the web servers supported by Symfony?
Symfony support various web servers that are given below:

  • WAMP (Windows)
  • LAMP (Linux)
  • XAMP (Multi-platform)
  • MAMP (Macintosh)
  • Nginx (Multi-platform)
  • Microsoft IIS (Windows)
  • PHP built-in development web server (Multi-platform)

18. What is Serializer in Symfony?
In Symfony, Serializer is a component that provides an option to convert a PHP object into a specific format such as XMLL, JSON, Binary etc.

19. How to create a request object in Symfony?
In Symfony, createFromGlobals() method is used to create a request object in Symfony.

20. What is Twing?
Twing is a powerful templating language of Symfony. It performs whitespace control, sandboxing and automatic HTML escaping.

21. Does Symfony framework support component to work with database?
No, Symfony does not support component to work with database.

22. What is the syntax of EmailType in Symfony?
In Symfony, the following syntax of EmailType is:

use Symfony\Component\Form\Extension\Core\Type\EmailType;

$builder->add(‘token’, EmailType::class, array(

‘data’ => ‘abcdef’, ));

23. What are the form helper functions in Symfony?
In Symfony, the form helper functions are given below:

  • Form_start
  • Form_end
  • Textarea
  • Checkbox
  • Input_password_tag etc.

24. What is the syntax to check valid email address?
The following syntax is used to check valid email address.

use Symfony\Component\Validator\Constraints as Assert;

class Student {

/**

* @Assert\Email(

* message = “The email ‘{{ value }}’ is not a valid email.”,

* checkMX = true

* )

*/

protected $email;

}

25. What is the default port of Symfony?
The default port of Symfony is 8000.

26. Which method is used to handle an Ajax request in the server side.
The following methods are used to handle an Ajax request in the server side.

if ($request->isXmlHttpRequest()) {

// Ajax request

} else {

// Normal request

}

27. What is the use of FlashBag?
FlashBag is used to hold the data during the page redirections.

28. In which language Symfony was written?
Symfony is written in PHP language.

29. What are the cache adapters available in Symfony?
In Symfony, the cache adapters available are given below:

  • Array Cache adapter
  • Filesystem Cache adapter
  • PHP Files Cache Adapter
  • APCu Cache Adapter
  • Redis Cache Adapter

Symfony PHP Framework Questions and Answers Pdf Download

Leave a Reply

Your email address will not be published. Required fields are marked *