I know that this question have been asked many times but I don't found a solution on the Web who correspond to my problem. So, I've create a UserBundle and when I try to access to the login page, I have the following error:
The autoloader expected class "ET\Bundle\UserBundle\Controller\SecurityController" to be defined in file "C:\xampp\htdocs\lab/src\ET\Bundle\UserBundle\Controller\SecurityController.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
I've check my file if my namespace or my class name are good, but I can't find the mistake.
My SecurityController :
<?php
namespace ET\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\SecurityContext;
class SecurityController extends Controller{
public function loginAction(Request $request){
// Si le visiteur est déjà identifié, on le redirige vers l'accueil
if ($this->get('security.context')->isGranted(IS_AUTHENTIFICATED_REMEMBERED)){
return $this->redirect($this->generateUrl('et_home'));
}
$session = $request->getSession();
// On vérifie qu'il n'y a pas d'erreurs lors d'un précédente soumission de formulaire
if($request->attributes->has(SecurityContext::AUTHENTIFICATION_ERROR)){
$error = $request->attributes->get(SecurityContext::AUTHENTIFICATION_ERROR);
}else{
$error = $session->get(SecurityContext::AUTHENTIFICATION_ERROR);
$session->remove(SecurityContext::AUTHENTIFICATION_ERROR);
}
return $this->render('ETUserBundle:Security:login.html.twig', array(
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
));
}
}
My firewall :
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
# the login page has to be accessible for everybody
main:
pattern: ^/
anonymous: true
provider: in_memory
form_login:
login_path: login
check_path: login_check
logout:
path: logout
target: /
My router :
login:
pattern: /login
defaults: { _controller: ETUserBundle:Security:login }
login_check:
pattern: /login_check
logout:
pattern: /logout
If anyone have an idea for me please. Thanks in advance. I've tried this on Symfony 2.6 and 2.7, with a new installation.
SecurityController.php
? – M Khalid JunaidET\Bundle\UserBundle\Controller
,Bundle after ET – M Khalid Junaid