1

我做了一个新的捆绑包,做了一个新的控制器,做了几个实体

当我使用 php 控制台 dotrine:schema:update --force 时,实体确实进入了数据库

我制作了一个表格,表格弹出很好,当我提交时我使用

if ($form->isValid()) {
                // perform some action, such as saving the task to the database

                $em = $this->getDoctrine()->getEntityManager();
                $em->persist($type);
                $em->flush();


                return $this->redirect($this->generateUrl('_success'));
            }

我得到一个很大的错误:

Naus\Biobalance\Entity\Sample 类不是有效的实体或映射的超类。

我已经仔细检查了我的顶部..并使用 Naus\bundle\Entity\Sample; 像它应该被提及的那样被提及?网上没有明确的答案,希望有人能帮助..

实体的第一行(根据要求)

<?php 

namespace Naus\Biobalance\Entity;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="sample")
 */
class Sample
{

关于appkernel:

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
            new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),

            new Knplabs\Bundle\MenuBundle\KnplabsMenuBundle(),
            new Knplabs\Bundle\SnappyBundle\KnplabsSnappyBundle(),
            new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
            new AntiMattr\GoogleBundle\GoogleBundle(),
            new Fp\OpenIdBundle\FpOpenIdBundle(),

            new Naus\Api\NausApi(),
            new Naus\App\NausApp(),
            new Naus\Cms\NausCms(),
            new Naus\Crm\NausCrm(),
            new Naus\Event\NausEvent(),
            new Naus\Form\NausForm(),
            new Naus\Invoicing\NausInvoicing(),
            new Naus\Mail\NausMail(),
            new Naus\Media\NausMedia(),
            new Naus\Member\NausMember(),
            new Naus\Meta\NausMeta(),
            new Naus\Project\NausProject(),
            new Naus\Vacancy\NausVacancy(),
            new Naus\Workgroup\NausWorkgroup(),
            new Naus\Biobalance\NausBiobalance(),
4

1 回答 1

1

显然,设置 config.yml 中的 auto_mapping 设置可以解决问题。

于 2012-05-01T20:57:39.110 回答