symfony framework code example

Example 1: create symfony project

symfony new my_project_name --full

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

Example 3: create symfony project

/usr/bin/composer create-project symfony/skeleton /home/handwork/symfony
#create symfony projet de base
# un dossier cacher du meme nom du projet serai creer