I hope to get Id from table User using repository in my action :
$user = $this->getDoctrine()->getRepository('AppMyBundle:User')
->findByUsername($token['name']);
$id = $user['id']; // also $user->id or $user->getId() give me error?
that give me this error :
Notice: Undefined index: id in /var/www/project/src/App/MyBundle/Controller/DefaultController.php line 56
finally the var_daump output :
echo "<pre>";
var_dump($user);
exit();
echo "</pre>";
array(1) {
[0]=>
object(App\MyBundle\Entity\User)#351 (21) {
["id":protected]=>
int(17)
....
....