PHP code example of viduc / casbundle

1. Go to this page and download the library: Download viduc/casbundle 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/ */

    

viduc / casbundle example snippets


        
        namespace App\Security;
        
        use Viduc\CasBundle\Security\CasUser;
        
        class User extends CasUser
        {
        
        }
        

        
        
        namespace App\Security;
        
        use Viduc\CasBundle\Security\UserProvider;
        use App\Security\User;
        
        class UserPersoProvider extends UserProvider
        {
            public function chargerUtilisateurParSonLogin($username)
            {
                $user = new User();
                $user->setUsername($username);
                $user->setRoles(['ROLE_USER']);
        
                return $user;
            }
        }
        

            /**
         * Tells Symfony to use this provider for this User class.
         */
        public function supportsClass($class)
        {
            return User::class === $class;
        }
        

	

	namespace App\Controller;

	use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
	use Symfony\Component\Routing\Annotation\Route;
	use App\Security\User;
	use Symfony\Component\HttpFoundation\Session\SessionInterface;

	class TestController extends AbstractController
	{
		public function __construct(SessionInterface $session)
		{
			$user1 = new User();
			$user1->setUsername('test1');
			$user1->setRoles(['ROLE_USER']);
			$user2 = new User();
			$user2->setUsername('test2');
			$user2->setRoles(['ROLE_USER']);
			$users[] = $user1;
			$users[] = $user2;
			$session = $session;
			$session->set('enTantQue.users', $users);
		}

		/**
		 * @Route("/test", name="test")
		 */
		public function index()
		{
			return $this->render('test/index.html.twig', [
				'controller_name' => 'TestController',
			]);
		}
	}