Confidence
Confidence

Reputation: 2303

Symfony2 FOSUserBundle and groups error

i am getting an error, when applying

php app/console doctrine:schema:update --force

i get a stack of errors, starting with

PHP Fatal error:  Declaration of Tracker\MembersBundle\Entity\User::addGroup() must be 

compatible with that of FOS\UserBundle\Model\GroupableInterface::addGroup() in C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\src\Tracker\MembersBundle\Entity\User.php on line 14
PHP Stack trace:
PHP   1. {main}() C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\app\console:0
PHP   2. Symfony\Component\Console\Application->run() C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\app\console:22
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\vendor\symfony\src\Symfony\Component\Console\Application.php:118
PHP   4. Symfony\Component\Console\Application->doRun() C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\vendor\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:75

i figured out User::addGroup() and the groups implementation of FOSUserBundle ...but i do not know how to ultimately solve it...here are my two entities

User Group

Update: if i simply remove addGroup() from the User Entity, and go to the path http://mysite.com/app_dev.php/group/new i get a fatal error

 Fatal error: Declaration of FOS\UserBundle\Form\Type\GroupFormType::getDefaultOptions() must be compatible with that of Symfony\Component\Form\FormTypeInterface::getDefaultOptions() in C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\vendor\bundles\FOS\UserBundle\Form\Type\GroupFormType.php on line 18

Upvotes: 0

Views: 2579

Answers (2)

Bilegsaikhan
Bilegsaikhan

Reputation: 134

you should remove from:

vendor\yourBundle\Entity\User;

getter setter group function coz it was already declared on

use FOS\UserBundle\Model\User.php;

it can be duplicate function !

now generate your schema i hope it helps you :D

Upvotes: 1

Mun Mun Das
Mun Mun Das

Reputation: 15002

You have to add FQCN of GroupableInterface in your User class e.g

use FOS\UserBundle\Model\GroupableInterface;

Edit:

You have to update symfony. As they have changed function signature of getDefaultOptions. Check here.

Upvotes: 2

Related Questions