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! :)

图片转代码服务由CSDN问答提供 功能建议

执行此操作后: $ php app / console doctrine:generate:entities AppBundle / Entity / Item

我收到此错误:

[RuntimeException] 自动加载器预期类“AppBundle \ Entity \ Item”到 在文件“/home/user/symfony-projects/demo/src/AppBundle/Entity/Item.php”中定义。 找到该文件但该类不在其中,类名或命名空间可能有拼写错误。

这是我的实体文件: \ n

  // 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)\  n * / 
 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; 
} \  n   
 
 

所以我检查了所有的拼写错误,并用Google搜索了大约半小时,并且没有看到此错误的来源。 有任何想法吗? 谢谢:)

因为它说我的帖子主要是代码,所以我必须写更多内容......但是我应该告诉你更多什么? 我喜欢蛋糕,咖啡和香烟! :)

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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 :)

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题