【问题标题】:Symfony2 - 'The class XXX was not found in the chain configured namespacesSymfony2 - '在链配置的命名空间中找不到类 XXX
【发布时间】:2023-03-02 23:58:01
【问题描述】:

我在 Symfony2 应用程序中收到以下错误

'在链配置的命名空间 StockSolutions\UserBundle\Entity、StockSolutions\ShopBundle\Entity、Vlabs\MediaBundle\Entity、FOS\UserBundle\Model 中找不到类 'Stocksolutions\ShopBundle\Entity\Image''

恕我直言,这有点奇怪,因为 StockSolutions\ShopBundle\Entity 位于配置的命名空间中。当我安装 vlabs media-bundle 时出现此错误。

这是我的图像实体

<?php

namespace Stocksolutions\ShopBundle\Entity; 

use Doctrine\ORM\Mapping as ORM;
use Vlabs\MediaBundle\Entity\BaseFile as VlabsFile;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Stocksolutions\ShopBundle\Entity\Image
 *
 * @ORM\Entity
 * @ORM\Table(name="image")
*/
class Image extends VlabsFile
{
    /**
     * @var string $path
     *
     * @ORM\Column(name="path", type="string", length=255)
     * @Assert\Image()
     */
    private $path;

    /**
     * Set path
     *
     * @param string $path
     * @return Image
     */
    public function setPath($path)
    {
        $this->path = $path;

            return $this;
    }

    /**
     * Get path
     *
     * @return string
     */
    public function getPath()
    {
        return $this->path;
    }
}

我在 config.yml 文件中有auto_mapping: true

有谁熟悉这个问题?

【问题讨论】:

    标签: symfony doctrine


    【解决方案1】:

    我觉得你应该写

    namespace StockSolutions\ShopBundle\Entity; 
    

    而不是

     namespace Stocksolutions\ShopBundle\Entity;
    

    【讨论】:

      猜你喜欢
      • 2015-11-12
      • 2021-08-09
      • 2021-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-17
      • 2019-08-10
      • 2014-12-11
      相关资源
      最近更新 更多