0

我需要帮助来弄清楚为什么 VichUploaderBundle 映射不存在。我正在使用带有 EasyAdmin 和 ORM 原则的 VichUploaderBundle。我的 vich_uploader.yaml 文件

vich_uploader:
    db_driver: orm

    mappings:
        products:
            #uri_prefix: '%app.path.node_images%'
            uri_prefix: '%app.path.product_images%'
             #uri_prefix: /products
            #upload_destination: '%kernel.root_dir%/../web%app.path.node_images%'
            upload_destination: '%kernel.root_dir%/../web/%app.path.product_images%'   

类调试说有映射

root@92d9f528832e:/app# php bin/console vich:mapping:debug-class 
App\\Entity\\Node
Introspecting class App\Entity\Node:
Found field "imageFile", storing file name in "image" and using mapping 
"product_images"

但是映射调试器找不到

root@92d9f528832e:/app# php bin/console vich:mapping:debug 
product_images
In MappingDebugCommand.php line 37:                                     
Mapping "product_images" does not exist.

这是我的课

namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

/**
 * @ORM\Entity
 * @ORM\Table(name="nodes")
 * @ORM\Entity(repositoryClass="App\Repository\NodeRepository")
 * @Vich\Uploadable
 */
class Node
{
    /**
     * @Vich\UploadableField(mapping="product_images", fileNameProperty="image")
     *
     * @var File
     */
    private $imageFile;
    /**
     * @ORM\Column(type="datetime")
     * @var \DateTime
     */

这是我的学说安装输出:

  doctrine/annotations                v1.6.0             Docblock Annotations Parser
  doctrine/cache                      v1.8.0             Caching library offering an object-oriented API for many cache backends
  doctrine/collections                v1.5.0             Collections Abstraction library
  doctrine/common                     v2.10.0            PHP Doctrine Common project is a library that provides additional functi...
  doctrine/dbal                       v2.8.0             Database Abstraction Layer
  doctrine/doctrine-bundle            1.10.0             Symfony DoctrineBundle
  doctrine/doctrine-cache-bundle      1.3.5              Symfony Bundle for Doctrine Cache
  doctrine/doctrine-migrations-bundle v1.3.1             Symfony DoctrineMigrationsBundle
  doctrine/event-manager              v1.0.0             Doctrine Event Manager component
  doctrine/inflector                  v1.3.0             Common String Manipulations with regard to casing and singular/plural ru...
  doctrine/instantiator               1.1.0              A small, lightweight utility to instantiate objects in PHP without invok...
  doctrine/lexer                      v1.0.1             Base library for a lexer that can be used in Top-Down, Recursive Descent...
  doctrine/migrations                 v1.8.1             Database Schema migrations using Doctrine DBAL
  doctrine/orm                        v2.6.3             Object-Relational-Mapper for PHP
  doctrine/persistence                v1.1.0             The Doctrine Persistence project is a set of shared interfaces and funct...
  doctrine/reflection                 v1.0.0             Doctrine Reflection component
  opsway/doctrine-dbal-postgresql     v0.8.1             Extensions for support Postgres in Doctrine DBAL & DQL
  symfony/doctrine-bridge             v4.2.0             Symfony Doctrine Bridge

vich/uploader-bundle                1.8.5
4

1 回答 1

0

我错误地将映射命名为“products”而不是“product_images”。

于 2018-12-17T15:47:46.837 回答