1

I'm trying to use VichUploaderBundle to handle a file upload. I work with symfony 4. I have a problem in the first step (Step 1: configure an upload mapping).

in the app/config/config.yml file I have:

vich_uploader:
    db_driver: orm

mappings:
    property_image:
        uri_prefix: /images/properties
        upload_destination: '%kernel.project_dir%/public/images/properties'

But it creates an error:

(2/2) FileLoaderLoadException There is no extension able to load the configuration for "mappings" (in C:\wamp64\www\MonAgence\config/packages/vich_uploader.yaml). Looked for namespace "mappings", found "framework", "sensio_framework_extra", "doctrine_cache", "doctrine", "doctrine_migrations", "security", "swiftmailer", "web_profiler", "twig", "monolog", "debug", "maker", "web_server", "doctrine_fixtures", "knp_paginator", "vich_uploader" in C:\wamp64\www\MonAgence\config/packages/vich_uploader.yaml (which is loaded in resource "C:\wamp64\www\MonAgence\config/packages/vich_uploader.yaml").

I searched the internet but I don't see how to fix it. Do you have an idea?

Pierrick Rambaud
  • 1,726
  • 1
  • 20
  • 47
lcgd
  • 45
  • 6
  • (Is it the grafikart lesson ?) Have you register the bundle in your kernel ? – Pierrick Rambaud Dec 21 '19 at 22:14
  • 1
    @Pierrick Rambau Hello, Thank you for your reply. Yes it is this lesson. I followed the lesson procedure. I'm not sure I understand. I added "Vich\UploaderBundle\VichUploaderBundle :: class => ['all' => true]," in config / bundles.php Are you talking about that? – lcgd Dec 21 '19 at 22:29
  • I think that I see about what you are talking. It is the step that is skipped in the lesson ( https://github.com/dustin10/VichUploaderBundle/blob/master/docs/installation.md#enable-the-bundle ).But I don't understand how to do it. – lcgd Dec 21 '19 at 23:23
  • The error message that your receive means that for Symfony noOne is supposed to read the config file and then it gives your the list of the readable confis. In the lesson they skip this part becaus normally you use the receipe which add the bundle (this was what I mean). If you've don it by yourself the problem is elsewhere. – Pierrick Rambaud Dec 22 '19 at 07:35
  • Bad indentation for key mapping ? – lwillems Dec 23 '19 at 06:50
  • why did you unaccept my answer for a false one ? – Pierrick Rambaud Feb 18 '20 at 21:48

2 Answers2

0

Got it,

Your package is loaded normally, it is specified in your error because it looks for the config of

"vich_uploader"

The problem comes from the

"mappings"

which doesn't exist.

mapping is part of the vich_uploader config so it should be indented inside like this:

vich_uploader:
    db_driver: orm

    mappings:
        property_image:
            uri_prefix: /images/properties
            upload_destination: '%kernel.project_dir%/public/images/properties'
Pierrick Rambaud
  • 1,726
  • 1
  • 20
  • 47
  • Thank you for your help. The problem comes from these lines. if I delete these lines, I no longer have the error. Same results with your solution. I no longer have the error, but it does not work.I will continue to search with this. – lcgd Dec 22 '19 at 11:12
  • but you're right, this is how it should be. I will continue to search with this. – lcgd Dec 22 '19 at 13:00
  • what's the next error ? If it's link, post it in the comment, if it's not don't forget to accept the answer – Pierrick Rambaud Dec 22 '19 at 14:05
  • the other errors were independent. You have helped me a lot. thank you – lcgd Dec 22 '19 at 16:13
-1

it works without the line break.

vich_uploader:
    db_driver: orm
    mappings:
        property_image:
            uri_prefix: /images/properties
            upload_destination: '%kernel.project_dir%/public/images/properties'
  • It has nothing to do with the line break. I've answered this question month ago (and for no reason I've been downvoted this morning). In your answer the important thing is the tabulation that you've added before `mapping`. – Pierrick Rambaud Feb 18 '20 at 21:43