sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
451 stars 495 forks source link

The target-entity Application\Sonata\ClassificationBundle\Entity\Category cannot be found in 'App\Application\Sonata\MediaBundle\Entity\Media#category'. #1630

Closed HecFranco closed 4 years ago

HecFranco commented 5 years ago

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.54.0 3.54.0 The missing Symfony Admin Generator     
sonata-project/block-bundle              3.18.1 3.18.1 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/cache-bundle              3.1.0  3.1.0  This bundle provides caching services   
sonata-project/classification-bundle     3.9.0  3.9.1  Symfony SonataClassificationBundle      
sonata-project/core-bundle               3.17.0 3.17.0 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.5.0  3.0.1  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.3.1  1.3.1  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.10.0 3.10.0 Symfony Sonata / Integrate Doctrine...  
sonata-project/easy-extends-bundle       2.5.0  2.5.0  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  2.0.1  2.0.1  Lightweight Exporter library
sonata-project/media-bundle              3.20.1 3.20.1 Symfony SonataMediaBundle
sonata-project/notification-bundle       3.6.2  3.6.2  Symfony SonataNotificationBundle        
sonata-project/seo-bundle                2.7.0  2.7.0  Symfony SonataSeoBundle
sonata-project/user-bundle               4.5.0  4.5.0  Symfony SonataUserBundle

Symfony packages

$ composer show --latest 'symfony/*'
 show --latest 'symfony/*'
Restricting packages listed in "symfony/symfony" to "4.3.*"
symfony/asset                      v4.3.4  v4.3.5  Symfony Asset Component
symfony/cache                      v4.3.4  v4.3.5  Symfony Cache component with PSR-6, PSR...
symfony/cache-contracts            v1.1.5  v1.1.7  Generic abstractions related to caching     
symfony/config                     v4.3.4  v4.3.5  Symfony Config Component
symfony/console                    v4.3.4  v4.3.5  Symfony Console Component
symfony/debug                      v4.3.4  v4.3.5  Symfony Debug Component
symfony/dependency-injection       v4.3.4  v4.3.5  Symfony DependencyInjection Component       
symfony/doctrine-bridge            v4.3.4  v4.3.5  Symfony Doctrine Bridge
symfony/dotenv                     v4.3.4  v4.3.5  Registers environment variables from a ...  
symfony/event-dispatcher           v4.3.4  v4.3.5  Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.5  v1.1.7  Generic abstractions related to dispatc...  
symfony/expression-language        v4.3.4  v4.3.5  Symfony ExpressionLanguage Component        
symfony/filesystem                 v4.3.4  v4.3.5  Symfony Filesystem Component
symfony/finder                     v4.3.4  v4.3.5  Symfony Finder Component
symfony/flex                       v1.4.6  v1.4.6  Composer plugin for Symfony
symfony/form                       v4.3.4  v4.3.5  Symfony Form Component
symfony/framework-bundle           v4.3.4  v4.3.5  Symfony FrameworkBundle
symfony/http-foundation            v4.3.4  v4.3.5  Symfony HttpFoundation Component
symfony/http-kernel                v4.3.4  v4.3.5  Symfony HttpKernel Component
symfony/inflector                  v4.3.4  v4.3.5  Symfony Inflector Component
symfony/intl                       v4.3.4  v4.3.5  A PHP replacement layer for the C intl ...  
symfony/maker-bundle               v1.13.0 v1.13.0 Symfony Maker helps you create empty co...  
symfony/mime                       v4.3.4  v4.3.5  A library to manipulate MIME messages       
symfony/options-resolver           v4.3.4  v4.3.5  Symfony OptionsResolver Component
symfony/polyfill-intl-icu          v1.12.0 v1.12.0 Symfony polyfill for intl's ICU-related...  
symfony/polyfill-intl-idn          v1.12.0 v1.12.0 Symfony polyfill for intl's idn_to_asci...  
symfony/polyfill-mbstring          v1.12.0 v1.12.0 Symfony polyfill for the Mbstring exten...  
symfony/polyfill-php72             v1.12.0 v1.12.0 Symfony polyfill backporting some PHP 7...  
symfony/polyfill-php73             v1.12.0 v1.12.0 Symfony polyfill backporting some PHP 7...  
symfony/process                    v4.3.4  v4.3.5  Symfony Process Component
symfony/profiler-pack              v1.0.4  v1.0.4  A pack for the Symfony web profiler
symfony/property-access            v4.3.4  v4.3.5  Symfony PropertyAccess Component
symfony/routing                    v4.3.4  v4.3.5  Symfony Routing Component
symfony/security-acl               v3.0.2  v3.0.2  Symfony Security Component - ACL (Acces...  
symfony/security-bundle            v4.3.4  v4.3.5  Symfony SecurityBundle
symfony/security-core              v4.3.4  v4.3.5  Symfony Security Component - Core Library   
symfony/security-csrf              v4.3.4  v4.3.5  Symfony Security Component - CSRF Library   
symfony/security-guard             v4.3.4  v4.3.5  Symfony Security Component - Guard
symfony/security-http              v4.3.4  v4.3.5  Symfony Security Component - HTTP Integ...  
symfony/service-contracts          v1.1.6  v1.1.7  Generic abstractions related to writing...  
symfony/stopwatch                  v4.3.4  v4.3.5  Symfony Stopwatch Component
symfony/swiftmailer-bundle         v3.2.8  v3.2.8  Symfony SwiftmailerBundle
symfony/templating                 v4.3.4  v4.3.5  Symfony Templating Component
symfony/translation                v4.3.4  v4.3.5  Symfony Translation Component
symfony/translation-contracts      v1.1.6  v1.1.7  Generic abstractions related to transla...  
symfony/twig-bridge                v4.3.4  v4.3.5  Symfony Twig Bridge
symfony/twig-bundle                v4.3.4  v4.3.5  Symfony TwigBundle
symfony/validator                  v4.3.4  v4.3.5  Symfony Validator Component
symfony/var-dumper                 v4.3.4  v4.3.5  Symfony mechanism for exploring and dum...  
symfony/var-exporter               v4.3.4  v4.3.5  A blend of var_export() + serialize() t...  
symfony/web-profiler-bundle        v4.3.4  v4.3.5  Symfony WebProfilerBundle
symfony/web-server-bundle          v4.3.4  v4.3.5  Symfony WebServerBundle
symfony/yaml                       v4.3.4  v4.3.5  Symfony Yaml Component

PHP version

$ php -v

PHP 7.2.18 (cli) (built: Apr 30 2019 23:32:39) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans

Subject

I have this mistake: "The target-entity Application\Sonata\MediaBundle\Entity\Media cannot be found in 'App\Appl
ication\Sonata\ClassificationBundle\Entity\Category#media'.".

Steps to reproduce

I followed the installation instructions of the official documentation and when launching the server I found that error inside the media option. I try to update the database and the console says to me:

$ php bin/console doctrine:schema:update --force

In MappingException.php line 772:

  The target-entity Application\Sonata\MediaBundle\Entity\Media cannot be found in 'App\Application\Sonata\ClassificationBundle\Entity\Category#media'.  

I have the demo uploaded on my github : https://github.com/HecFranco/Sonata-project-complete-demo.

Expected results

Update the database and be able to launch the server correctly.

Actual results

The target-entity Application\Sonata\MediaBundle\Entity\Media cannot be found in 'App\Application\Sonata\ClassificationBundle\Entity\Category#media'.

phansys commented 5 years ago

Thank you for the report @HecFranco! Could you please update the description using the issue template?

phansys commented 5 years ago

Maybe the problem is related to the absence of an entity registered under a Doctrine manager. I think you should check this configuration in your example.

HecFranco commented 5 years ago

You could extend a little more the @phansys answer, I don't understand you, the entity I think is declared. I don't know exactly what you want to tell me.

phansys commented 5 years ago

I mean, you should check the configuration for Doctrine ORM (ref.):

doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    ApplicationSonataMediaBundle: ~
                    SonataMediaBundle: ~

If you need more information than the provided in the docs or if you found some steps that are not working as expected, please check the DoctrineBundle configuration or follow the instructions at "Support" section to get support.

Thank you so much.

HecFranco commented 5 years ago

Thanks for the @phansys answer, I've also tried that configuration you told me about, but it didn't work either. Do you know of any sonata sandbox for symfony 4 that works well?

HecFranco commented 5 years ago

@phansys I checked the configuration again, including what you said and I get the same error (I leave here the repo: https://github.com/HecFranco/sonata-complete-bundle)

tonyellow commented 4 years ago

I have this same bug, what can we do to fix it?

franmomu commented 4 years ago

Looks like you should define the category under sonata_media.class.

simonspts commented 4 years ago

I had the same problem and I solved it by adding this into sonata_classification.yaml:

media: App\Application\Sonata\MediaBundle\Entity\Media

Also put into sonata_media.yaml:

category: App\Application\Sonata\ClassificationBundle\Entity\Category

I found the solution in official documentation.

tonyellow commented 4 years ago

Looks like you should define the category under sonata_media.class.

Thanks, this fixed it for me.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.