PHP code example of tom32i / simple-security-bundle
1. Go to this page and download the library: Download tom32i/simple-security-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/ */
tom32i / simple-security-bundle example snippets
php composer.phar
$bundles = array(
new Tom32i\Bundle\SimpleSecurityBundle\Tom32iSimpleSecurityBundle(),
);
namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Tom32i\Bundle\SimpleSecurityBundle\Entity\User as SimpleSecurityUser;
/**
* User
*
* @ORM\Table
* @ORM\Entity
*/
class User extends SimpleSecurityUser
{
const ROLE_USER = 'ROLE_USER';
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->addRole(static::ROLE_USER);
}
/**
* Get available roles (used for validation)
*
* @return array
*/
static public function getAvailableRoles()
{
return [static::ROLE_USER];
}
}