dustin10 / VichUploaderBundle

A simple Symfony bundle to ease file uploads with ORM entities and ODM documents.
MIT License
1.85k stars 519 forks source link

PHP 8 example broken: Mapping not found for field "imageFile" #1259

Closed olivier1980 closed 2 years ago

olivier1980 commented 2 years ago

There are 2 examples for making a Product entity in https://github.com/dustin10/VichUploaderBundle/blob/master/docs/usage.md.

The line '#[Vich\UploadableField(mapping: 'img', fileNameProperty: 'imageName', size: 'imageSize')]' should set a UploadableField property. Problem is, the jms/metadata that is supposed to detect the metadata for the class will not recognize this php 8 syntax. So either the JMS dependency should be set to one that is PHP 8 compatible, or the docs should not give PHP 8 examples.

garak commented 2 years ago

What is the JMS version compatible with PHP 8?

olivier1980 commented 2 years ago

I don't know..all I see is that the example for php 8 doesn't work, and I traced it to the JMS library...on a related note, the '#[ORM\Column(type: 'integer')]' notation for the orm fields didn't get picked up by the Symfony migrations:diff command either

olivier1980 commented 2 years ago

Nevermind, I found the answer, in Symfony you must declare if you're using annotation vs properties..https://stackoverflow.com/questions/66769981/how-can-i-use-php8-attributes-instead-of-annotations-in-doctrine