我有一个名为“杂志”的实体,从 yml 文件映射:
Acme\DemoBundle\Entity\Magazine:
type: entity
table: magazine
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
edition:
type: string
length: 255
nullable: false
title:
type: text
nullable: false
cover:
type: string
length: 255
nullable: false
file:
mapping: magazine_cover
filename_property: cover
我在 app/config/config.yml 中进行了必要的配置:
knp_gaufrette:
stream_wrapper: ~
vich_uploader:
db_driver: orm
mappings:
magazine_cover:
uri_prefix: /upload/magazine/cover
upload_destination: %kernel.root_dir%/../web/upload/magazine/cover
delete_on_remove: true
实体文件:
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\PropertyMapping as Vich;
我没有这样工作,在“杂志”表中创建了一个字段“文件”,这不应该发生。我发现一些文章解释了如何使用注释进行配置,但是 yml 我什么也没找到。