PHP code
Template code
Console Commands
Mixed topics
Concepts
100

Name of the parent class that our controller must inherit in order to use the render method

AbstractController

100

Code to show the result of executing the function "exemplo()" on the screen

{{var}}

100

Command to stop the Symfony development server

symfony server:stop

100

Name of the file where we can see the list of packages that are installed in our project

composer.json

100

What is the name of the templating engine for Symfony?

Twig

200

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)

200

Code to write the comment "This is an example"

{# This is an example #}

200

Command to install the Profiler

composer require debug

200

Where are the third party libraries installed in our project?

In the vendor directory

200

What is a JSON controller?

A controller that returns data in json format

300

Indicate the name of the namespace if we create a class called Motorbike in the directory vehicles in the controller directory

App\Controller\vehicles

300

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 }}

300

Command that we must execute in order to know all the information of the routes defined in our project

php bin/console debug:router

300

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

300

What is Webpack Encore used for?

Webpack is the industry standard tool for packaging, minifying and parsing your frontend CSS, JavaScript, and other files

400

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)

400

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') }}">

400

Command to list all the services in our app

php bin/console debug:autowiring

400

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')]

400

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

500

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();

500

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' }}

500

Command to start the WebPack encore

npm run watch

500

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

500

What is a recipe in Symfony flex?

The recipes are files that contain the instructions that allow the automatic configuration of packages

M
e
n
u