Name of the parent class that our controller must inherit in order to use the render method
AbstractController
Code to show the result of executing the function "exemplo()" on the screen
{{var}}
Command to stop the Symfony development server
symfony server:stop
Name of the file where we can see the list of packages that are installed in our project
composer.json
What is the name of the templating engine for Symfony?
Twig
Code that we must write so that a JSON controller returns the contents of the array $cars
return $this->json($cars)
(return Json Response($cars) is also valid)
Code to write the comment "This is an example"
{# This is an example #}
Command to install the Profiler
composer require debug
Where are the third party libraries installed in our project?
In the vendor directory
What is a JSON controller?
A controller that returns data in json format
Indicate the name of the namespace if we create a class called Motorbike in the directory vehicles in the controller directory
App\Controller\vehicles
The filter called first returns the first element of an array. Write the code to show the first element of the array [1,2,3,4]
{{ [1, 2, 3, 4]|first }}
Command that we must execute in order to know all the information of the routes defined in our project
php bin/console debug:router
Command that we must execute in the console so that Node reads the file package.json and redownloads all the packages indicated there
npm install
What is Webpack Encore used for?
Webpack is the industry standard tool for packaging, minifying and parsing your frontend CSS, JavaScript, and other files
Find the error in the following code and correct it:
<?php
namespace App\Controller;
class Example{
function exercise(){
$date = new DateTime();
}
}
use DateTime()
(\DateTime() is also valid)
Suppose we are working on a Twig template and we need to add a CSS link to a checkout.css file that lives at public/css/. How would you do that?
<link rel="stylesheet" href="{{ asset('css/checkout.css') }}">
Command to list all the services in our app
php bin/console debug:autowiring
Write the Route definition for the url /miApp followed by a wildcard called variable and give that route the name myRoute
#[Route('/miApp/{variable}', name:'myRoute')]
What is Composer?
Composer is an application-level dependency manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries
Code that we must add in our controller if we want to create an object of the class Coche that is defined in the namespace net\iessanclemente
$obxCoche = new \net\iessanclemente\Coche();
Other possible answer:
use net\iessanclemente;
...
$obxCoche = new Coche();
Simplified if (in one line) that checks the value of the variable "number": if it is greater than or equal to zero it will show "Greater than zero" on the screen if it is less than zero it will show "Smaller than zero" on the screen.
{{ number >= 0 ? 'Greater than zero' : 'Smaller than zero' }}
Command to start the WebPack encore
npm run watch
Explain with your words what happens behind the scenes when you type: symfony new projectName
You clone the repository at https://github.com/symfony/skeleton and you run composer install to download vendor libraries
What is a recipe in Symfony flex?
The recipes are files that contain the instructions that allow the automatic configuration of packages