Reputation: 1395
I have a few errors during installation of Sonata Media Bundle on Symfony 4 application which had no place with Symfony 2.8.
The first error:
sensio/generator-bundle v3.1.6 requires symfony/framework-bundle ~2.7|~3.0
Next one, after solving the previous:
- php-amqplib/php-amqplib v2.7.0 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
Another one:
Unrecognized options "naming_strategy, auto_mapping, mappings" under "doctrine.orm"
And then, when I tried to clear the cache:
Class Application\Sonata\MediaBundle\ApplicationSonataMediaBundle not found in home/user/projects/svoya-fignia/config/services.yaml (which is loaded in resource "/home/user/projects/svoya-fignia/config/services.yaml").
or this one
Class Sonata\MediaBundle\PHPCR\BaseGalleryHasMediaRepository not found in home/user/projects/svoya-fignia/config/services.yaml (which is loaded in resource "/home/user/projects/svoya-fignia/config/services.yaml").
Upvotes: 2
Views: 2342
Reputation: 31
For the
Unrecognized options "naming_strategy, auto_mapping, mappings" under "doctrine.orm"
error, try to add the configurations in orm.entity_managers instead of in orm in your config/packages/doctrine.yaml, something like this:
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '5.7'
orm:
auto_generate_proxy_classes: true
#naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
#auto_mapping: true
#mappings:
# App:
# is_bundle: false
# type: annotation
# dir: '%kernel.project_dir%/src/Entity'
# prefix: 'App\Entity'
# alias: App
entity_managers:
default:
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
SonataUserBundle: ~
FOSUserBundle: ~
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
This is working with Symfony 4.4. Maybe this can help someone... I spent some hours with that error :/
Upvotes: 0
Reputation: 1395
I found the solutions for all of them, but it took some time, so I want to post it here for everyone who encounter this problem.
The first error with sensio/generator-bundle
is solved by requiring dev version of sonata-media-bundle
:
composer require sonata-project/media-bundle:3.x-dev
Solution for the next one is obvious, but anyway:
sudo yum install php-bcmath
or
sudo apt-get install php-bcmath
Unrecognized options problem is solved here: Symfony doctrine auto_mapping Unrecognized
And finally the problem with classes that are not found is caused by symfony autowiring and should be solved by adding Application
directory to excluded ones:
# services.yaml
services:
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests,Application}'
If you have something to add or my solutions are not the best, please let me know, and I will update this post.
Upvotes: 7