PHP code example of chaplean / user-bundle

1. Go to this page and download the library: Download chaplean/user-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chaplean / user-bundle example snippets



//...

use Chaplean\Bundle\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="<YourTableName>")
 */
class User extends BaseUser {
//...
}



namespace App\Bundle\FrontBundle\Controller;

use Chaplean\Bundle\UserBundle\Controller\LoginController as BaseController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\SecurityUtilityTest\Csrf\CsrfTokenManagerInterface;

/**
 * Class LoginController.
 */
class LoginController extends BaseController
{
    /**
     * @var CsrfTokenManagerInterface
     */
    protected $tokenManager;

    /**
     * LoginController constructor.
     *
     * @param CsrfTokenManagerInterface $tokenManager
     */
    public function __construct(CsrfTokenManagerInterface $tokenManager)
    {
        $this->tokenManager = $tokenManager;
    }

    /**
     * Renders the login page.
     *
     * @Route("/connexion-of")
     *
     * @return Response
     */
    public function loginAction()
    {
        return $this->render(
            'Login/login.html.twig',
            [
                'csrf_token' => $this->tokenManager->getToken('authenticate')->getValue()
            ]
        );
    }
}