相关疑难解决方法(0)

使用symfony的简单登录表单

这是我的控制器

use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;   

class SecurityController extends Controller
{
/**
 * @Route("/login", name="login")
 */
public function loginAction(Request $request,AuthenticationUtils $authUtils)
{
    // get the login error if there is one
    $error = $authUtils->getLastAuthenticationError();

    // last username entered by the user
    $lastUsername = $authUtils->getLastUsername();

    return $this->render('blog/login.html.twig', array(
            'last_username' => $lastUsername,
            'error'         => $error,
    ));
}
}
Run Code Online (Sandbox Code Playgroud)

这是我的security.yml

 providers:
    our_db_provider:
        entity:
            class: AppBundle:user
            property: uname

    in_memory:
        memory: 
            users:
                clement:
                  password: $2y$12$Z2B4JTnglzaYs4z73DBh9u/hIDN/E56CCrLKIjQxP6Q7aeLb5S6LO 
                  roles: 'ROLE_ADMIN'
                admin:
                  password: symfony
                  roles: 'ROLES_ADMIN' …
Run Code Online (Sandbox Code Playgroud)

php login symfony twig

7
推荐指数
1
解决办法
2915
查看次数

标签 统计

login ×1

php ×1

symfony ×1

twig ×1