1.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.
In Symfony, we can get the request parameter using following method:
$request = $this->container->get('request');
$name=$request->query->get('name'); // Get Methond
// $_POST parameters
3. In which technology, routing configuration files are written?
Routing configuration files are written in the following technology:
- YAML
- PHP
- XML
Default routing configuration file is: app/config/routing.yml
5.How to create a request object in Symfony?
In Symfony, createFromGlobals() method is used to create a request object in Symfony.
6.What is the default port of Symfony?
The default port of Symfony is 8000.
7.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.
8.What is the use of FlashBag?
FlashBag is used to hold the data during the page redirections.
9.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
10.Which Template Engine Symfony Supports?
Symfony default template engine is Twig, however, your are free to use plain PHP code if you want.
11. What Are Bundles In Symfony?
Answer :
Symfony bundle are very similar to plugins or packages in other frameworks or CMS. In Symfony, everything is a bundle from core framework components to code you write.The bundle gives the flexibility to use pre-built features packaged in third-party bundles or to create and distribute your own bundles.
There are two types of bundles are available in Symfony :
- Application-specific bundles: only used to build your application.
- Reusable bundles: meant to be shared across many projects
12.How To Get The Current Route In Symfony Framework?
Answer :
You can get current route in Symfony using $request->get(‘_route’); method
13.How To Set And Get Session In Symfony2?
Answer :
SessionInterface object set and get method is used to set and get sessions in Symfony2.
Below look below 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');
}
14.How To Get The Request Parameters In Symfony2?
Answer :
$request->query->get(‘paraemeter_name’) method is used to get the request parameters in symfony2.
15.What Are Descriptors In Symfony?
Answer :
Descriptors are objects to render documentation on Symfony Console Apps.
16.How To Create A Symfony Application Using Composer?
Answer :
Run below command in your console to install Symfony using Composer:
composer create-project symfony/framework-standard-edition my_project_name
17. what are the form helper functions in symfony ?
Symfony has following form helper functions for developers:
- Checkbox
- Form_start
- Form_end
- Textarea
- Input_password_tag
18. How to get current route in symfony ?
$request->get("_route");
{{ app.request.attributes.get('_route') }} // In Twig
19. What is method to Kernel’s class enable bundles in Symfony?
Kernel’s class registerBundles() method is used to enable bundles in Symfony.
20. What rules you follow while creating methods in controller using symfony ?
General rules for creating a method in within the controller in Symfony.
- Only action methods should be public.
- Controller methods should be short; if your controller is long, consider refactoring it.
- Action methods must have the “Action” suffix
- Action methods should return a valid response object
22. What are path for views, models,controller,routes files in symfony ?
View folder path is {# templates/user/notifications.html.twig #}
Controller file path : src/Controller/UserController.php
Model File Path : src/Service/MessageGenerator.php
Routes File Path : config/routes.yaml
config/routes.xml
config/routes.php
No comments:
Post a Comment