I would like to use vich uploader in my easy admin interface. After installing it, I've created the vich_uploader.yaml file (it is not generating alone in my case). I've follow the tutorial in the symfony page, but when I want to use it, an error occured :
"There is no extension able to load the configuration for "vich_uploader""
I really don't understand why, here is my files :
easy_admin.yaml :
easy_admin:
entities:
Project:
list:
fields:
- { property: 'photo_1', type: 'image', base_path: '%app.path.project_images%' }
show:
fields:
- { property: 'photo_1', type: 'image', base_path: '%app.path.project_images%' }
form:
fields:
- {property: 'photo_1File', type: 'vich_image'}
vich_uploader.yaml :
vich_uploader:
db_driver: orm
mappings:
project_images:
uri_prefix: '%app.path.project_images%'
upload_destination: '%kernel.project_dir%/public%app.path.project_images%'
My project entity looks like :
/**
* @ORM\Entity(repositoryClass=ProjectRepository::class)
* @Vich\Uploadable
*/
class Project
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @var string
*/
private $photo_1;
/**
* @Vich\UploadableField(mapping="project_images", fileNameProperty="photo_1")
* @var File
*/
private $photo_1File;
public function getPhoto1(): ?string
{
return $this->photo_1;
}
public function setPhoto1(?string $photo): self
{
$this->photo_1 = $photo;
return $this;
}
public function setPhoto1File(File $image = null)
{
$this->photo_1File = $image;
if ($image) {
$this->updatedAt = new \DateTime('now');
}
}
public function getPhoto1File()
{
return $this->photo_1File;
}
services.yaml :
parameters:
app.path.project_images: /uploads/images/projects
I've the line "vich/uploader-bundle": "^1.15"
in my composer.json. It looks like symfony doesn't found the package...
Add to bundles.php
:
Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],
This will activate the bundle for all environment, not only dev and test otherwise it won't be available on live environment