Skip to content

Instantly share code, notes, and snippets.

@romaricdrigon
Created April 12, 2019 14:55
Show Gist options
  • Save romaricdrigon/1ca0e2cc0df7aa72afcb03119336856e to your computer and use it in GitHub Desktop.
Save romaricdrigon/1ca0e2cc0df7aa72afcb03119336856e to your computer and use it in GitHub Desktop.
But de l'article "Récupérer plus simplement l'utilisateur dans un contrôleur Symfony"
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\User\UserInterface;
class MyController extends AbstractController
{
/**
* @Route("/dashboard", name="dashboard")
*/
public function index(Request $request, UserInterface $user)
{
return new Response(sprintf('Hello %s', $user->getUsername());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment