简体   繁体   中英

Vich uploader bundle: mapping doesn't exist

I need help to figure out why a VichUploaderBundle mapping doesn't exist. I'm using VichUploaderBundle with EasyAdmin and ORM doctrine. My vich_uploader.yaml file

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%'   

Class debugging says the mapping is there

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"

But mapping debugger can't find it

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

Here's my class

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
     */

Here is my doctrine installation output:

  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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM