Home >> Interviews Q & A >> Symfony Interview Questions and Answers

Symfony Interview Questions and Answers

Symfony Interview Questions: Symfony Interview Questions and Answers. Symfony is a set of reusable PHP components and a PHP framework to build web applications, APIs etc
Q:- What is Symfony?

>> Symfony is a web application framework, written in PHP

>> Symfony is a set of reusable PHP components to build web applications, APIs, microservices and web services.

>> Symfony support MVC design pattern.

Q:- What are the benefits of using Symfony?
  1. Fast Development:

    Reusing generic components/Libraries- Symfony provides many such components and libraries which can be reused.

  2. MVC Pattern:

    Symfony supports MVC design pattern.

  3. Unlimited flexibility
  4. Expandable
  5. Stable and sustainable
  6. Ease of use.
Q:- How to install Symfony Application using Composer?
Installing & Setting up the Symfony Framework

>> To create your new Symfony application, first make sure you're using PHP 7.1 or higher and have Composer installed

>> Run the following command in cmd to install Symfony using Composer

composer create-project symfony/website-skeleton myFirstProject

The website-skeleton is optimized for traditional web applications. If you are building microservices, console applications or APIs, consider using the much simpler skeleton project:

composer create-project symfony/skeleton myFirstProject

cd myFirstProject
composer require symfony/web-server-bundle --dev
Running your Symfony Application

>> Move into your new project and start the server:

cd myFirstProject
php bin/console server:run

Open your browser and navigate to http://localhost:8000 If everything is working, you'll see a welcome page.

You may also like - Top 50 Laravel Interview Questions
Q:- How to get the request parameters in Symfony2?

Syntax: $request->query->get("paraemeter_name");

use Symfony\Component\HttpFoundation\Request;

public function updateAction(Request $request)
    // $_GET parameters

    // $_POST parameters

//You can also get all the form values as array by using the following:
Q:- Which Template Engine does Symfony Support?

Symfony default template engine is Twig, however, your are free to use plain PHP code if you want.

Q:- How to get the current route in Symfony?

You can get current route in Symfony using following code:


//OR with Twig 
{{ app.request.attributes.get('_route') }}

You may also like - RESTful Web Services Interview Questions
Full Stack Tutorials

Author @FullStackTutorials | View all Articles