2

I have installed FOSUserBundle and followed the example in this link: http://symfony.com/doc/current/bundles/FOSUserBundle/index.html and each time I try to login symfony shows me this exception:

Notice: Array to string conversion
500 Internal Server Error - ContextErrorException

So this is my class User that extneds from BaseUser:

namespace OCUserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use FOS\UserBundle\Model\User as BaseUser ;
/**
 * User
 *
 * @ORM\Table(name="user")
 * @ORM\Entity(repositoryClass="OCUserBundle\Repository\UserRepository")
 */
class User extends BaseUser
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;


}

securit.yml:

providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        main:
            pattern: ^/
            provider: fos_userbundle
            form_login:
                login_path: fos_user_security_login
                check_path: fos_user_security_check
            logout:
                path:       fos_user_security_logout
                target:     /platform
            anonymous:    true

and this is my routing.yml:

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

and this is the table in my database:
image link

So what am I missing?

2 Answers 2

0

Does your OCUserBundle override FOSUserBundle ?

namespace UserBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class OCUserBundle extends Bundle
{
    public function getParent()
    {
        return 'FOSUserBundle';
    }
}

It also may need that you configure fos_user options in config.yml:

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: OCUserBundle\Entity\User

(And when in doubt, always clear the cache).

Sign up to request clarification or add additional context in comments.

Comments

0

you forgot the constructor in your user class:

public function __construct()
    {
        parent::__construct();
        // your own logic
    }

and maybe in your config:

fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: OCUserBundle\Entity\User

4 Comments

Nope, the constructor exist and the configuration is correct but still no results
affound the solution this problem in vertion to symfony
can you explain the problem?
the default present betwin the version in symfony3 and symfony 2.so after changed the version to 2.8 th'is problem result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.