1) What is Symfony?
Symfony is an open-source web application framework. It is a set of PHP Components and a leading PHP framework to create websites and dynamic web applications. It follows the MVC design pattern and is released under the MIT License.
2) What is the current Stable version of Symfony?
The current stable version of Symfony is 3.3.2, and it was released on 6 June 2017.
3) What are the benefits of Symfony?
Symfony framework has the following benefits, such as:
Fast development
MVC Pattern
Unlimited user flexibility
Expandable
It is a stable and sustainable framework
It has a better user control
4) What are the components in Symfony?
Symfony Components are a set of decoupled and reusable PHP libraries. It is open-source software that aims to speed up the creation and maintenance of web applications, replace repetitive coding tasks, build robust applications in an enterprise context, and give developers full control over the configuration.
5) Does Laravel use Symfony?
Yes, Laravel uses Symfony components internally. Around 30% of the Laravel framework is built on Symfony.
6) What are the server requirements to install the Symfony?
You require the following server requirements to install and run the Symfony framework, such as:
PHP 5.5.9 or greater
Composer
JSON enabled
ctype enabled
timezone should be set (default timezone will not work)
7) What is a Symfony Controller?
Symfony controller is a PHP function that obtains information from the HTTP request to construct and return an HTTP response. The response can vary and could be an XML document, an HTML page, a redirect, a 404 error, a serialized JSON array, or any other request.
8) What are Bundles in Symfony?
Symfony bundles are very similar to plugins or packages in other frameworks or CMS. In Symfony, everything is a bundle, from core framework components to the code you write. The bundle gives the flexibility to use pre-built features packaged in third-party bundles or create and distribute your own bundles. 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.
9) How many types of bundles are in Symfony?
There are two types of bundles are available in the Symfony framework:
10) Explain the tasks performed by the Symfony controller?
A Symfony controller can do virtually anything inside this framework. From redirecting and forwarding to accessing core services to rendering templates, a controller in Symfony can be used for various basic tasks.
11) Which template engine Symfony supports?
By default, Symfony uses a twig template engine. Twig is a flexible, fast, secure, and open-source template engine for PHP and originates its syntax from Jinja and Django templates. It is licensed under a BSD License and maintained by Fabien Potencier. However, you are free to use plain PHP code if you want.
12) Symfony logs are stored in which directory?
Symfony stores all logs in the log directory of your project.
13) Explain an environment in the Symfony framework?
A group of configurations used to run an application is described as an Environment in Symfony. This framework has two default environments:
Prod: It is used to optimize for executing an application on production.
Dev: It is used when an application is developed locally.
14) What are Annotations in Symfony?
In the Symfony framework, Annotations are used for the configuration of validation and mapping Doctrine information. Annotations are easy and convenient to use. In the 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.
15) State the Symfony framework application?
There are various Symfony framework applications, such as:
Thelia
Drupal 8
Daily motion
16) Symfony is a Configuration or Convention-based framework?
Symfony is a convention-based framework.
17) How to get the current route in the Symfony framework?
You can get current route in Symfony using $request->get(‘_route’); method.
18) How to get the list of all installed packages in Composer?
The composer show command is used to list all installed packages/dependencies of your current project.
19) When Symfony denies user access?
Symfony denies user access when an unauthorized user tries to access a web application; it throws a 403 HTTP status and error page.
20) How to create and remove sessions in Symfony Framework?
In Symfony Session, the 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 sessions 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’);
21) How to check the installed version of Symfony?
If you have access to the command line, then you can use the php bin/console about the command to view the installed version of the Symfony framework. You can get the version of Symfony in the symfony/src/Symfony/Component/HttpKernel/Kernel.php file.
22) What are Descriptors in Symfony?
Descriptors are objects in Symfony that are used to render documentation and information on the console.
23) What are the form helper functions in Symfony?
The form helpers provide a faster way to write form inputs in templates, especially for complex elements such as dates, drop-down lists, and rich text. Here are some form helper functions of Symfony framework,
form_tag()
input_tag()
input_password_tag()
input_hidden_tag()
textarea_tag()
input_file_tag()
select_tag()
options_for_select()
checkbox_tag()
submit_tag().
24) What is Serializer in Symfony?
In Symfony, a serializer is a component that allows converting a PHP object into a specific format such as XMLL, JSON, Binary, etc.
25) What are the innovations in Symfony2?
Here are the following innovations that provide Symfony 2, such as:
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.
26) How to get the current route in Symfony?
You can get current route in Symfony using following code:
$request->get(“_route”); //OR with Twig {{ app.request.attributes.get(‘_route’) }}
27) How many cache adapters are present in Symfony?
The five cache adapters are available in the Symfony framework.
File system cache adapter
Array cache adapter
APCu cache adapter
PHP files cache adapter
Redis cache adapter
28) How to set and get Session in Symfony 2?
SessionInterface object set and get method is used to set and get sessions in Symfony2. For example:
public function sessionAction(SessionInterface $session)
{
// store an attribute for reuse during a later user request
$session->set(‘user_id’, 5);
// get the attribute set by another controller in another request
$user_id = $session->get(‘user_id’);
}
29) What is Symfony 2?
Symfony 2 is a full-stack web framework written in PHP. It is a reusable set of standalone, decoupled, and cohesive PHP components that solve web development problems. Symfony 2 introduced unique HTTP and HTTP cache handling by being an HTTP-centric request or response framework. It also allows full use of advanced features such as ESI to separate the different parts of your page or application.
Symfony 2 is powered out of the box by fast PHP-built Symfony reverse proxy, and for mid to large installations, a seamless upgrade to varnish provides a 10-20x speedup and a far more robust cache handling.
Leave a Reply