I was following this tutorial. Problem for me occured when i was trying to install friends of symfony user-bundle and/or oauth-server-bundle via composer.
Only thing I found out googling was someone asking same question 12 days ago https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/issues/638
I would not recommend FOSUserBundle. Nowaydays it's not really necessary anymore as Symfony's security component together with the docs or the MakerBundle delivers most of what you need the bundle for.
If you insist on using it, try setting up the bundle configuration in your config.yml and then try composer require again. In your case the problem is the missing configuration for the bundle, see Step 5: Configure the FOSUserBundle in the docs.
# app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb' and 'couchdb'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
As you can see the missing first section db_driver is exactly what your error message complains about.
Related
I tried to install symfony 4.4 instead. after the installation, I tried to install sonata user bundle and got this error:
The child node "db_driver" at path "fos_user" must be configured.
then I followed this link
https://stackoverflow.com/a/49034641 to create fos_user.yaml
and I got this error:
The service "fos_user.mailer.default" has a dependency on a non-existent service "templating".
then I followed this link
FriendsOfSymfony/FOSUserBundle#2679 (comment)
and I got this error:
The service "sonata.user.admin.user" has a dependency on a non-existent service "sonata.admin.manager.orm".
and I followed this link:
#1050 (comment)
and I got this error:
There is no extension able to load the configuration for "fos_user" (in "/fsys1/home/public_html/mycel7/config/packages/fos_user.yaml"). Looked for namespace "fos_user", found ""framework", "sensio_framework_extra","twig", "web_profiler", "monolog", "debug", "maker", "doctrine", "doctrine_migrations", "security", "twig_extra", "knp_menu", "sonata_doctrine", "sonata_twig", "sonata_form", "sonata_block", "sonata_exporter", "sonata_admin","sonata_doctrine_orm_admin"" in /fsys1/home/public_html/mycel7/config/packages/fos_user.yaml (which is loaded in resource "/fsys1/home/public_html/mycel7/config/packages/fos_user.yaml").
at this step I am not sure what to do then.
This is my config/packages/fos_user.yaml :
fos_user: db_driver: orm firewall_name: main user_class: Entity\User from_email: address: "test#gmail.com" sender_name: "test"
This is my config/packages/framework.yaml:
framework: secret: '%env(APP_SECRET)%' session: handler_id: null cookie_secure: auto cookie_samesite: lax #esi: true #fragments: true php_errors: log: true templating: engines: twig
symfony version is 4.4.
other files are un-touched
With Symfony flex, one of the change is that there is no default bundle when using the symfony/skeleton.
I don't find a way to use the command doctrine:mongodb:generate:documents in this context.
Could you please tell me how to use it ?
Exemple:
php bin\console doctrine:mongodb:generate:documents App
2018-02-17T18:35:22+00:00 [error] Error thrown while running command "doctrine:mongodb:generate:documents AppBundle --document Test". Message: "No bundle AppBundle was found."
In DoctrineODMCommand.php line 87:
No bundle AppBundle was found.
doctrine:mongodb:generate:documents [--document [DOCUMENT]] [--no-backup] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <bundle>
This is how I setup my project
composer create-project symfony/skeleton:3.4 test
composer config "platform.ext-mongo" "1.6.16" && composer require "alcaeus/mongo-php-adapter"
composer require doctrine/mongodb-odm-bundle
Thanks
Regards,
Chris
There is a similar issue with doctrine orm and doctrine:generate:entities. The Doctrine team discourages users from using these commands and therefore does no longer want to maintain them.
I think the easiest workaround I've seen so far is:
Create a Symfony 3.3 style application using the Symfony installer.
Generate the entities in the AppBundle as you did before
Change the namespace from AppBundle to App.
Move the files into your Symfony 4 project.
Some of the Symfony team also set out to provide similar code generation in a MakerBundle. As far as I can tell there is nothing for generating ODM-style entities, but you could open an issue or contribute something for this yourself.
For reference see: https://github.com/doctrine/DoctrineBundle/issues/729
The MongoDBBundle requires you have "Bundle" but with Symfony flex you are using FrameworkBundle and not "AppBundle" unless you created it before, I think you have not created it, so it tells you that it does not exist.
You can not use the "FrameworkBundle" either beacause FrameworkBundle have other namspace and other base path, so the command to generate the documents does not know where the files are.
After a lot of time figuring out how to diry-fix it:
Create custom Bundle inside your project (EX: AppCoreBundle)
Define custom mapping inside packages/doctrine_mongodb.yaml (change type value if you use xml or yaml)
doctrine_mongodb:
auto_generate_proxy_classes: '%kernel.debug%'
auto_generate_hydrator_classes: '%kernel.debug%'
connections:
default:
server: '%env(MONGODB_URL)%'
options: {}
default_database: '%env(MONGODB_DB)%'
document_managers:
default:
auto_mapping: true
mappings:
AppCoreBundle:
is_bundle: true
type: annotation
dir: '/Document'
prefix: App\CoreBundle\Document
alias: AppCoreBundle
Change the directory "src" to "App" to avoid issues then update psr-4 namaspace inside composer.json: "App\\": "App/"
Move all Documents to the Bundle Document directory and change package names.
You will also have to change ALL references to "src" directory in your project, for example in services.yaml.
Then execute: rm -rf var/cache/* && composer install to force to clear cache and refs.
Then execute: php bin/console doctrine:mongodb:generate:documents AppCoreBundle
Important!
This solution solves compatibility problems with MongoODMBundle with Symfony 4 but it is not a correct way. The right fix involves modifying the behavior of the bundle or Symfony 4.
It has been now 2 days that i'm looking for a solution to this error but in vain :
Unknown Entity namespace alias 'PirastruFormBuilderBundle'
in fact i installed the sonata form builder with sonata page bundle using the composer but i don't know why i'm getting this error.
i don't know which part of codes should i copie here so please don't hesitate to ask me for it
sonata_form_builder:
resource: '#PirastruFormBuilderBundle/Controller/FormBuilderController.php'
type: annotation
Thanks !!
EDIT
when i run this : php app/console config:dump-reference
PirastruFormBuilderBundle | pirastru_form_builder |
and when i run this : php app/console doctrine:mapping:info i got
[Exception] You do not have any mapped Doctrine ORM entities
according to the current configuration. If you have entities or
mapping files you should check your mapping configuration for errors.
well i managed to solve the problem ! i had just to add a getManager in my FormBuilderBlockService
This problem can be caused by some (mis)configurations :
Bundle
app/console config:dump-reference
This command let you know if the Bundle is referenced.
Mapping
app/console doctrine:mapping:info
This command let you know if the Bundle is mapped.
It's typically a mapping issue :
Unknown Entity namespace alias '***Bundle'
The better solution is to add auto_mapping to true in config.yml, like this :
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
But it can be solved by others way, you can have a look to : Symfony : What is the meaning of auto_mapping and auto_generate_proxy_classes
Best regards,
I followed this tutorial to install SonataAdmin with FOSUserBundle.
Now i keep getting this Error Message:
No entity manager defined for class Application\Sonata\UserBundle\Entity\User
But how do i set/pass the EntityManager?
I haven't found anything about configuring it or any hint on what this error means.
Any help anyone?
Edit #1:
As asked for, here is what i have in my config.yml for sonata so far:
sonata_block:
default_contexts: [cms]
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
sonata.block.service.text:
sonata.block.service.rss:
Edit #2:
I added the entity manager configuration part for Doctrine2 ORM Admin thou it is mentioned in the Documentation that if left null, it should just use the default. Still, it doesn't solve my problem.
sonata_doctrine_orm_admin:
# default value is null, so doctrine uses the value defined in the configuration
entity_manager: '#doctrine.orm.entity_manager'
Edit #3:
I did set auto_mapping to true as well, even thou that also is true by default.
Still no Solution to this Problem.
When you use
php app/console sonata:admin:generate
it requests for fully qualified model class, so you'd write something like:
\Acme\DemoBundle\Entity\DemoEntity
the problem is, that when generator creates service for you it adds line:
arguments: [~, \Acme\DemoBundle\Entity\DemoEntity, AcmeDemoBundle:DemoEntityAdmin]
That breaks it.
It works with:
arguments: [~, Acme\DemoBundle\Entity\DemoEntity, AcmeDemoBundle:DemoEntityAdmin]
Notice missing "\" before Acme\Demo....
What was missing in my config.yml was:
doctrine:
[...]
orm:
[...]
entity_managers:
default:
mappings:
ApplicationSonataUserBundle: ~
SonataUserBundle: ~
Just had this problem.
Make sure you easy-extended the SonataUserBundle:
php app/console sonata:easy-extends:generate SonataUserBundle
and are loading it in AppKernel.php
new Application\Sonata\UserBundle\ApplicationSonataUserBundle(),
See documentation here:
https://github.com/sonata-project/SonataUserBundle/blob/master/Resources/doc/reference/installation.rst
Then the automapping is enough and you don't need to define manual mapping.
When I'm trying to install FOSUserBundle I'm getting the following error:
Fatal error: Call to undefined method Symfony\Bundle\DoctrineBundle\Registry::getManager() in W:\symproject\app\cache\dev\appDevDebugProjectContainer.php on line 1039
What can it be?
I've also tried to install FOSUserBundle to a pure Symfony Standart Edition and encountered the same issue.
I followed along this documentation.
You probably have installed latest FOSUserBundle which is used for Symfony2.1.x
If you are using Symfony2.0.x change your deps file:
[FOSUserBundle]
git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
target=bundles/FOS/UserBundle
version=1.2.0
then reinstall the vendors with:
php bin/vendors install
I have been using FOS User Bundle for a long time, and this weekend my automatic build stopped working with exactly the error you wrote here. So for me I then found the solution :)
It seems like the latest version of FOS User Bundle has a bug, so I added this to the deps.lock file:
FOSUserBundle f487dc16cec6003c46542a90d5193761fd91360a
In deps file I have:
[FOSUserBundle]
git=http://github.com/FriendsOfSymfony/FOSUserBundle.git
target=bundles/FOS/UserBundle
And voila! It now works!
(The commit f487d... was just chosen from the commits 4 days ago - when I know it was working)
This should fix your problem!
I've updated from 2.0.16 to 2.1 dev-master with composer, got the same error...
my solution:
In orm.xml
factory-service="doctrine" factory-method="getManager"
replace with
factory-service="doctrine" factory-method="getEntityManager"
Also if you are using Symfony 2.0.x there's not such method as getManager, instead you have to use getEntityManager to get it working.
i think you have missed Doctrine ORM mapping in config.yml
doctrine:
orm:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
mappings:
FOSUserBundle: ~
try this hope this will work...