PHP Symfony MCQ Questions & Answers
Symfony MCQs : This section focuses on "Symfony" PHP Framework. These Multiple Choice Questions (MCQ) should be practiced to improve the PHP Symfony skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. Which of the following is true about Symfony?
A. Symfony is an open-source MVC framework for rapidly developing modern web applications
B. Symfony is a full-stack web framework
C. Symfony contains a set of reusable PHP components
D. All of the above
View Answer
Ans : D
Explanation: Symfony is an open-source MVC framework for rapidly developing modern web applications. Symfony is a full-stack web framework. It contains a set of reusable PHP components.
2. Which of the following is not a features of Symfony Framework?
A. Model-View-Controller based system
B. High-performance PHP framework
C. Set of coupled components
D. Error logging
View Answer
Ans : C
Explanation: Set of decoupled and reusable components is a features of Symfony Framework.
3. In MVC, which represents the structure of our business entities?
A. Model
B. View
C. Controller
D. None of the above
View Answer
Ans : A
Explanation: Symfony web framework is based on Model-View-Controller (MVC) architecture. Model represents the structure of our business entities. View shows the models to the user in the best possible way depending on the situation. Controller handles all the request from the user.
4. Symfony core web-framework is a bundle called?
A. CacheBundle
B. SymfonyBundle
C. ExtraBundle
D. FrameworkBundle
View Answer
Ans : D
Explanation: Symfony core web-framework is a bundle called FrameworkBundle and there is a bundle called FrameworkExtraBundle, which provides more sophisticated options to write a web application.
5. In Symfony, the Console component can be installed using?
A. symfony/console
B. composer require symfony/console
C. composer symfony/console
D. require symfony/console
View Answer
Ans : B
Explanation: The Console component can be installed using the following command.
composer require symfony/console
6. ClassLoader component provides implementation for?
A. PSR-0
B. PSR-1
C. PSR-2
D. PSR-3
View Answer
Ans : A
Explanation: ClassLoader component provides implementation for both PSR-0 and PSR-4 class loader standard.
7. Which component provides various options to read and write an object and array details using the string notation?
A. PropertyInfo
B. ClassLoader
C. PropertyAccess
D. Process
View Answer
Ans : C
Explanation: PropertyAccess component provides various options to read and write an object and array details using the string notation.
8. Which component provides various options to parse .env files?
A. Cache
B. Intl
C. OptionsResolver
D. Dotenv
View Answer
Ans : D
Explanation: Dotenv component provides various options to parse .env files and the variable defined in them to be accessible via getenv(), $_ENV, or $_SERVER.
9. VarDumper component provides better dump() function
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: VarDumper component provides better dump() function. Just include the VarDumper component and use the dump function to get the improved functionality.
10. Symfony provides an easy and efficient component, _____________ to handle object dependency
A. Objectdependency
B. DependencyInjection
C. componentInjection
D. Greeter
View Answer
Ans : B
Explanation: Symfony provides an easy and efficient component, DependencyInjection to handle object dependency. A service container is a container of objects with properly resolved dependency between them
11. The process of event based programming can be summarized as - An object, called?
A. Event dispatcher
B. source
C. Event source
D. dispatcher
View Answer
Ans : C
Explanation: The process of event based programming can be summarized as - An object, called Event source asks the central dispatcher object to register an event, say user.registered.
12. A ____________ is a collection of files and folders organized in a specific structure.
A. AppBundle
B. Symfony app
C. Blog Bundle
D. Symfony bundle
View Answer
Ans : D
Explanation: A Symfony bundle is a collection of files and folders organized in a specific structure. The bundles are modeled in such a way that it can be reused in multiple applications. The main application itself is packaged as a bundle and it is generally called AppBundle.
13. Symfony also provides a console command ________ to simplify the process of creating a new bundle
A. AppKernel:bundle
B. generate:bundle
C. controller:bundle
D. tests:bundle
View Answer
Ans : B
Explanation: Symfony also provides a console command generate:bundle to simplify the process of creating a new bundle, which is as follows.
php bin/console generate:bundle --namespace = LFC/DemoBundle
14. In general, any URI has?
A. 2 parts
B. 5 parts
C. 3 parts
D. 4 parts
View Answer
Ans : C
Explanation: In general, any URI has the following three parts : Hostname segment, Path segment, Query segment.
15. If you want to redirect the user to another page, use the ?
A. redirectToRoute()
B. redirect()
C. Both A and B
D. None of the above
View Answer
Ans : C
Explanation: If you want to redirect the user to another page, use the redirectToRoute() and redirect() methods.
16. Which layer is the presentation layer of the MVC application?
A. Model
B. View
C. Controller
D. All of the above
View Answer
Ans : B
Explanation: A View Layer is the presentation layer of the MVC application. It separates the application logic from the presentation logic.
17. Symfony uses a powerful templating language called
A. Twig
B. Swig
C. Pwig
D. Dwig
View Answer
Ans : A
Explanation: Symfony uses a powerful templating language called Twig. Twig allows you to write concise and readable templates in a very easy manner. Twig templates are simple and won't process PHP tags.
18. Twig do not performs whitespace control, sandboxing, and automatic HTML escaping
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : B
Explanation: False, Twig performs whitespace control, sandboxing, and automatic HTML escaping.
19. A controller in Symfony is a
A. YAML function
B. PHP function
C. XML Config file
D. All of the above
View Answer
Ans : B
Explanation: A controller in Symfony is a PHP function.
20. By default, the routing configuration file in a Symfony2 application is located at
A. .app/config/routing.yml
B. .app/config_route/routing.yml
C. .app/yaml/routing.yml
D. .app/config/routing.config
View Answer
Ans : A
Explanation: By default, the routing configuration file in a Symfony2 application is located at .app/config/routing.yml.
Discussion