dt2002 2015-02-18 18:22
浏览 40
已采纳

Symfony 2.6.4 - Doctrine,生成Getter和Setter,RuntimeException错误

After doing this: $ php app/console doctrine:generate:entities AppBundle/Entity/Item

I'm getting this error:

[RuntimeException] The autoloader expected class "AppBundle\Entity\Item" to be defined in file "/home/user/symfony-projects/demo/src/AppBundle/Entity/Item.php". The file was found but the class was not in it, the class name or namespace probably has a typo.

This is my entity file:

// src/AppBundle/Entity/Item.php
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="item")
 */
class Item
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=128)
     */
    protected $title;

    /**
     * @ORM\Column(type="integer")
     */
    protected $userid;

    /**
     * @ORM\Column(type="datetime")
     */
    protected $created;

    /**
     * @ORM\Column(type="string", lenght=64)
     */
    protected $type;

    /**
     * @ORM\Column(type="string", lenght=64)
     */
    protected $category;

    /**
     * @ORM\Column(type="string", lenght=64)
     */
    protected $subcategory;

    /**
     * @ORM\Column(type="string", lenght=64)
     */
    protected $location;

    /**
     * @ORM\Column(type="text")
     */
    protected $description;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    protected $image;
}

So I checked everything for a typo, and googled for about half an hour, and don't see where this error comes from. Any ideas? Thanks :)

So because it's saying my post is mostly code, I have to write something more.. but what should I tell you more? I like cake, coffee and cigarettes! :)

  • 写回答

1条回答 默认 最新

  • douli4852 2015-02-22 00:24
    关注

    got the problem...

    I indeed had some typos in my code.. I wrote lenght instead of length several times.. damn, not easy to see ;)

    Thanks for your help anyways :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?