symfony 5 what's new code example

Example 1: create new project symfony

# run this if you are building a traditional web application
$ symfony new my_project_name --full

# run this if you are building a microservice, console application or API
$ symfony new my_project_name

Example 2: symfony

<?php
// src/Controller/LuckyController.php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;

class LuckyController
{
    public function number(): Response
    {
        $number = random_int(0, 100);

        return new Response(
            '<html><body>Lucky number: '.$number.'</body></html>'
        );
    }
}

Tags:

Misc Example