Symfony 3 - Sonata Aplication Media Bundle error

LauraEld

I was following the official documentation to install Sonata Media Bundle, I think it worked until the step when I use this command:

php bin/console sonata:easy-extends:generate --dest=src SonataMediaBundle

Then I add new Application\Sonata\MediaBundle\ApplicationSonataMediaBundle(), to AppKernel.php.

After these steps, I try to enter to mi admin (localhost:8000/admin) but throws this error:

Attempted to load class "ApplicationSonataMediaBundle" from namespace "Application\Sonata\MediaBundle". Did you forget a "use" statement for another namespace?

I try to execute php bin/console doctrine:schema:create (or update) and the error continues:

ubuntu@ubuntu-xenial:/workdir/Testing$ php bin/console doctrine:schema:update --force
PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "ApplicationSonataMediaBundle" from namespace "Application\Sonata\MediaBundle".
Did you forget a "use" statement for another namespace? in /workdir/Testing/app/AppKernel.php:32
Stack trace:
#0 /workdir/Testing/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(450): AppKernel->registerBundles()
#1 /workdir/Testing/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(116): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /workdir/Testing/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(137): Symfony\Component\HttpKernel\Kernel->boot()
#3 /workdir/Testing/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(124): Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands()
#4 /workdir/Testing/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(90): Symfony\Bundle\FrameworkBundle\Console\Applica in /workdir/Testing/app/AppKernel.php on line 32

I verified that the routes were correct and followed steps just like the documentation, I've been looking for answers over the internet and found anything. Please help!

I tried to execute php bin/console sonata:easy-extends:generate --dest=src SonataMediaBundle without --dest=src to place folder in app/ but the error continues...

My config.yml according to the doc:

doctrine:
  dbal:
      driver: pdo_mysql
      host: '%database_host%'
      port: '%database_port%'
      dbname: '%database_name%'
      user: '%database_user%'
      password: '%database_password%'
      charset: UTF8
      types:
             json: Sonata\Doctrine\Types\JsonType
      # if using pdo_sqlite as your database driver:
      #   1. add the path in parameters.yml
      #     e.g. database_path: "%kernel.project_dir%/var/data/data.sqlite"
      #   2. Uncomment database_path in parameters.yml.dist
      #   3. Uncomment next line:
      #path: '%database_path%'

  orm:
      auto_generate_proxy_classes: '%kernel.debug%'
      naming_strategy: doctrine.orm.naming_strategy.underscore
      auto_mapping: true
      mappings:
           ApplicationSonataMediaBundle: ~
           SonataMediaBundle: ~

sonata_media:
  # if you don't use default namespace configuration
  #class:
  #    media: MyVendor\MediaBundle\Entity\Media
  #    gallery: MyVendor\MediaBundle\Entity\Gallery
  #    gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia
  db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here
  default_context: default # you need to set a context
  contexts:
      default:  # the default context is mandatory
          providers:
            - sonata.media.provider.dailymotion
            - sonata.media.provider.youtube
            - sonata.media.provider.image
            - sonata.media.provider.file
            - sonata.media.provider.vimeo

          formats:
            small: { width: 100 , quality: 70}
            big:   { width: 500 , quality: 70}

  cdn:
      server:
          path: /uploads/media # http://media.sonata-project.org/

  filesystem:
      local:
          directory:  "%kernel.root_dir%/../web/uploads/media"
          create:     false

And my routing.yml:

gallery:
   resource: '@SonataMediaBundle/Resources/config/routing/gallery.xml'
   prefix: /media/gallery

media:
   resource: '@SonataMediaBundle/Resources/config/routing/media.xml'
   prefix: /media

EDIT:

I think the problem is with Easy-Extends because I tried to install Classification Bundle and the same happens, does current Symfony version support Easy-Extends? Maybe because Sonata User Bundle is not compatible with current version (I tried this too)...

EDIT 2:

My composer.json file:

{
    "name": "vagrant/testing",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "AppBundle\\": "src/AppBundle"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        },
        "files": [
            "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
        ]
    },
    "require": {
        "php": ">=5.5.9",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/orm": "^2.5",
        "friendsofsymfony/user-bundle": "^2.0",
        "gedmo/doctrine-extensions": "^2.4",
        "incenteev/composer-parameter-handler": "^2.0",
        "pixassociates/sortable-behavior-bundle": "^1.3",
        "sensio/distribution-bundle": "^5.0.19",
        "sensio/framework-extra-bundle": "^3.0.2",
        "sonata-project/admin-bundle": "^3.20",
        "sonata-project/doctrine-orm-admin-bundle": "^3.1",
        "sonata-project/easy-extends-bundle": "^2.2",
        "sonata-project/media-bundle": "^3.6",
        "stof/doctrine-extensions-bundle": "^1.2",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/swiftmailer-bundle": "^2.3.10",
        "symfony/symfony": "3.3.*",
        "twig/twig": "^1.0||^2.0",
        "vich/uploader-bundle": "^1.6"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0"
    },
    "scripts": {
        "symfony-scripts": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "config": {
        "sort-packages": true
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": null
    }
}
Jakub Matczak

You need to add autoloader definition in your composer.json in a similar way that there is already for AppBundle.

As I understand, the new bundle is generated under path src/Application/Sonata/MediaBundle so it would be:

"autoload": {
    "psr-4": {
        "AppBundle\\": "src/AppBundle"
        "Application\Sonata\MediaBundle\\": "src/Application/Sonata/MediaBundle"
    },
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ]
},

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to validation to sonata media type in symfony 2

From Dev

Sonata Media Bundle Override

From Dev

how to override a css of sonata admin bundle in symfony2

From Dev

Display the Sonata Admin Bundle inside a view of a Symfony Bundle

From Dev

Issue Configuring Sonata Media Bundle with MongoDB

From Dev

How to get Sonata Media Bundle to generate pictures in separate folders

From Dev

sonata admin bundle symfony

From Dev

Sonata admin bundle preview image from some entity in list mapper without sonata media bundle

From Dev

Symfony Sonata Media Bundle add images/videos to a user

From Dev

Sonata Media Bundle + AWS S3 - specify subdirectory?

From Dev

The show action of Symfony 2 Sonata Admin Bundle is not working

From Dev

How to override default upload path of sonata media bundle in symfony?

From Dev

Sonata User Bundle error on profile edit

From Dev

Error in file upload with sonata-admin bundle

From Dev

Sonata User Bundle + Symfony 3.x

From Dev

Issue Configuring Sonata Media Bundle with MongoDB

From Dev

How to get Sonata Media Bundle to generate pictures in separate folders

From Dev

Sonata Media Bundle - How to extend FormatThumbnail.php

From Dev

error in sonata media bundle

From Dev

How to override default upload path of sonata media bundle in symfony?

From Dev

Sonata User Bundle error on profile edit

From Dev

Symfony 2 Sonata Media bundle: saving media file image without sonata admin

From Dev

Sonata Media Bundle with Sonata Admin Bundle 3.0 (or 2.4)

From Dev

Batch actions with Sonata Admin Bundle on Symfony

From Dev

Sonata admin bundle , Symfony2

From Dev

Image Upload Issue with Symfony3, Doctrine 2 and Sonata Admin Bundle

From Dev

Sonata Media Bundle Installation error

From Dev

API Post to Sonata Media Bundle Symfony 3

From Dev

Lexik Bundle Symfony 3

Related Related

  1. 1

    How to validation to sonata media type in symfony 2

  2. 2

    Sonata Media Bundle Override

  3. 3

    how to override a css of sonata admin bundle in symfony2

  4. 4

    Display the Sonata Admin Bundle inside a view of a Symfony Bundle

  5. 5

    Issue Configuring Sonata Media Bundle with MongoDB

  6. 6

    How to get Sonata Media Bundle to generate pictures in separate folders

  7. 7

    sonata admin bundle symfony

  8. 8

    Sonata admin bundle preview image from some entity in list mapper without sonata media bundle

  9. 9

    Symfony Sonata Media Bundle add images/videos to a user

  10. 10

    Sonata Media Bundle + AWS S3 - specify subdirectory?

  11. 11

    The show action of Symfony 2 Sonata Admin Bundle is not working

  12. 12

    How to override default upload path of sonata media bundle in symfony?

  13. 13

    Sonata User Bundle error on profile edit

  14. 14

    Error in file upload with sonata-admin bundle

  15. 15

    Sonata User Bundle + Symfony 3.x

  16. 16

    Issue Configuring Sonata Media Bundle with MongoDB

  17. 17

    How to get Sonata Media Bundle to generate pictures in separate folders

  18. 18

    Sonata Media Bundle - How to extend FormatThumbnail.php

  19. 19

    error in sonata media bundle

  20. 20

    How to override default upload path of sonata media bundle in symfony?

  21. 21

    Sonata User Bundle error on profile edit

  22. 22

    Symfony 2 Sonata Media bundle: saving media file image without sonata admin

  23. 23

    Sonata Media Bundle with Sonata Admin Bundle 3.0 (or 2.4)

  24. 24

    Batch actions with Sonata Admin Bundle on Symfony

  25. 25

    Sonata admin bundle , Symfony2

  26. 26

    Image Upload Issue with Symfony3, Doctrine 2 and Sonata Admin Bundle

  27. 27

    Sonata Media Bundle Installation error

  28. 28

    API Post to Sonata Media Bundle Symfony 3

  29. 29

    Lexik Bundle Symfony 3

HotTag

Archive