Skip to content

The class 'fuar\sergiBundle\Entity\Product' was not found in the chain configured namespaces #275

@erdemildiz

Description

@erdemildiz

I'm using Symfony with MongoDB. I'm getting this error. Why? Please Help me!

app/config.yml

doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: test_database
    document_managers:
        default:
            auto_mapping: true

Controller:

namespace fuar\sergiBundle\Controller;

use fuar\sergiBundle\Entity\Product;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class DefaultController extends Controller
{
    public function indexAction()
    {
        $product = new Product();
        $product->setName("xxx");
        $product->setAge('25');
        $product->setSchool("xxxx");

        $dm = $this->get('doctrine_mongodb')->getManager();
        $dm->persist($product);
        $dm->flush();

         return new Response('Created product id '.$product->getId());
    }
}

fuar/sergiBundle/Entity/Product.php

namespace fuar\sergiBundle\Entity;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * Product
 */
class Product
{
    /**
     * @var integer
     */
    private $id;

    /**
     * @var string
     */
    private $name;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions