FOSUserBundle redirect from login page after logged in

The easier solution is to add these two lines to your app/config/security.yml: always_use_default_target_path & default_target_path, e.g.: firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider login_path: /login check_path: /login_check always_use_default_target_path: false default_target_path: /your/start/path/

How do I get the entity that represents the current user in Symfony?

Symfony 4+, 2019+ Approach In symfony 4 (probably 3.3 also, but only real-tested in 4) you can inject the Security service via auto-wiring in the controller like this: <?php use Symfony\Component\Security\Core\Security; class SomeClass { /** * @var Security */ private $security; public function __construct(Security $security) { $this->security = $security; } public function privatePage() : Response … Read more

How to get the logged-in user’s ID in Symfony

Current Symfony versions (Symfony 4, Symfony >=3.2) Since Symfony >=3.2 you can simply expect a UserInterface implementation to be injected to your controller action directly. You can then call getId() to retrieve user’s identifier: class DefaultController extends Controller { // when the user is mandatory (e.g. behind a firewall) public function fooAction(UserInterface $user) { $userId … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)