Symfony interview questions

Symfony interview questions | Freshers & Experienced

  • Janhavi Jaiswal
  • 22nd Nov, 2019
  • 623 Followers

Q1. What is symfony? List some features?

Symfony is a complete web framework and set of reusable components that are easily used in other applications and frameworks. It is written by Fabien Potencier and first released on 22 October 2005.

Major Key Features of Symfony Framework are

  • Easy to install
  • Highly scalable
  • Open Source
  • Large and active Community.
  • Flexible routing.
  • Based on the MVC design pattern.
  • Clean and elegant template engine.
  • Easy testing and long-term support.
  • Good documentation

Q2. What are symfony bundles?

Symfony bundles are a directory or folder where we put all related files of a module. Generally, a Bundle contains the following directories and files.

  • Controller Directory: Contains controllers of the bundle
  • DependencyInjection Directory: Hold Dependency Injection Extension classes
  • Resources/config/ Directory: Contains configuration files like routing.yaml
  • Resources/views/ Directory: Contain view files of the bundle.
  • Resources/public/ Directory: Contains static resources such as images, stylesheets of a bundle.
  • Tests/ Directory: Contains all test files for the bundle.

Q3. What are components in symfony?

Q4. Does laravel use symfony?

Yes, Laravel uses Symfony components internally. Around 30% of Laravel framework is built on Symfony.

Q5. Symfony logs are stored in which directory?

Symfony stores all logs in log directory of your project.

Q6. How to clear cache in Symfony?

To clear cache in Symfony you can use cache:pool:clear command. This command will delete all data from the project storage directory. By default, Symfony comes with 3 cache clearers. They are

  • cache.global_clearer
  • cache.system_clearer
  • cache.app_clearer

Q7. How to create a bundle in Symfony?

The Symfony bundle is a group of files and directories that are organized into a specific structure.

To create a bundle in Symfony follow below steps:

Step1: Choose a namespace. The namespace must contain the name of the vendor and bundle name. Something like Courseya\DemoBundle.

Step2: Create an empty class named CourseyaDemoBundle and extend it to Bundle class.

Example:

namespace Courseya\DemoBundle; 
use Symfony\Component\HttpKernel\Bundle\Bundle;  

class CourseyaDemoBundle extends Bundle { 
}

Step3: Save the above class in src/Courseya/DemoBundle directory.

Step4: Register the above class in the bundle list supported by the application in the AppKernel class. Example:

public function registerBundles() { 
   $bundles = array( 
      // ... 
      // register your bundle 
      new Courseya\DemoBundle\CourseyaDemoBundle(), 
   ); 
   return $bundles; 
}

Step5: Use generate:bundle command to generate your bundle.

php bin/console generate:bundle --namespace = Courseya/DemoBundle

That's all you have created your first bundle in Symfony.

Q8. What are annotations in Symfony?

Annotations in Symfony are used for configuration of validation and mapping Doctrine information. Annotations are easy and convenient to use. In Standard Edition of Symfony, we have two additional bundles SensioFrameworkExtraBundle and JMSSecurityExtraBundle which provide better support for annotations. Using these bundles you can use annotations for controller configuration, routing, cache, security, template, etc

Q9. How to create and remove session in Symfony Framework?

In Symfony Session class is used to work with sessions. This class can perform all functions of native PHP sessions.

Below is an example of creating and removing session in Symfony.

Creating Session in Symfony

  $session = new Session();
  $session->start();

Setting Session in Symfony

  $session->set('user_id', 200);

Getting session in Symfony

 $session->get('user_id');

Removing / Destroying session in Symfony

  $session->remove('user_id');

About Author :

  • Author of Symfony interview questions

    Janhavi Jaiswal

    Janhavi is a Digital marketing expert and technical content writer. She like solving problems and delivering results that make positive impacts.She is quick learner.

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.

Explore Popular Courses on Symfony

Start working with Landrick that can provide everything you need to generate awareness, drive traffic, connect.