Getting troubles when trying to install FOSUserBundle to Symfony2 - symfony

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...

Related

Cannot install symfony with option --webapp

I try to install symfony v5.
Following the documentation, (https://symfony.com/doc/5.4/setup.html#creating-symfony-applications) i have the error "Incorrect usage: flag provided but not defined: --webapp".
Same error with symfony cli and composer.
How can i resolve this problem ? No help in the documentation... Each new version of symfony becomes more complicated. :-(
Thank you for your help.
Here's my configuration:
php: v7.3
symfony (CLI): v4.24.1
composer: v1.10.15
Maybe try to upgrade Your symfony version. For my symfony version (5.3.13) it works correctly

How to generate document with Symfony 3.4 using Symfony flex

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.

Symfony: ServiceNotFoundException after update

After updating my Symofny projet from 3.2.* to 3.3.* I faced this exception:
ServiceNotFoundException
The service "fos_user.profiler.controller" has a dependency on a non-existent service "fos_user.email_update_confirmation".
So you guys know these steps:
1- In order to optimize the performance I have launched this command:
composer dump-autoload --optimize --no-dev --classmap-authoritative
2- I did the upgrade from 3.2.* to 3.3.*
3- Did the same command as in the first step
After this I faced this exception !!
It's known problem. One of the PR on GH solves it. Now to fix it add
fos_user:
registration:
confirmation:
enabled: true
in config. Of course if you have existing fos_user in config just add that what is missing.

sf2 : Unknown "asset" function in "#Twig/Exception/exception_full.html.twig" at line 4

I'm using Symfony 3.1
I have this error when I run app_dev.php :
Unknown "asset" function in "#Twig/Exception/exception_full.html.twig"
at line 4.
I already checked my config.yml, and it contains these values :
framework:
assets:
base_path: ~
...
I don't know what to do... I hope someone can help me. Thank you !
EDIT : Problem solved. I had to remove custom twig filters in my config.yml... :)
Try to set:
assets: ~
Issue about same problem
https://github.com/symfony/symfony/issues/17291
Edit:
Please also check that`s symfony assets component was installed.
The symfony/asset component is required, even in 3.0, by the FrameworkBundle
As you can see:
https://github.com/symfony/framework-bundle/blob/master/composer.json
Another way run update symfony to latest version and update all depend

Sylius installing cart/orderBundle - service "sylius.translatable.listener" error

I'm trying to install only the cartBundle and orderBundle (with their dependencies) for my application. I'm still a newbie in sf2 so stop me if I'm wrong in my thinking.
So on packagist I found the lastest version :
"sylius/order-bundle": "0.14.*#dev"
But composer wouldn't install all the dependencies by itself (all the *#dev), so I had to manually add all of them to composer.json
After some time I finally got to the configuration of the bundles in app/config.yml and I added the bundles on top of appKernel.php.
But then I have this error :
ParameterNotFoundException in ParameterBag.php line 106: The service "sylius.translatable.listener" has a dependency on a non-existent parameter "sylius.translation.mapping". Did you mean this: "sylius.translation.default.mapping"?
I can't figure out what to do know. I probably missed something. I couldn't find the documentation for the translationBundle : http://docs.sylius.org/en/latest/bundles/SyliusTranslationBundle/index.html
If you have any idea, please let me know.
Thanks
just for curiosity:
i tried to use the
"sylius/taxonomy-bundle": "~0.13"
in my project and needed to manualy additonaly require
"sylius/translation-bundle": "~0.13",
"sylius/locale-bundle": "~0.13",
in symfony i also needed to add the bundles to the kernel:
new Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Sylius\Bundle\TranslationBundle\SyliusTranslationBundle(),
new Sylius\Bundle\LocaleBundle\SyliusLocaleBundle(),
and
#app/config/config.yml
sylius_taxonomy:
driver: doctrine/orm
classes:
taxonomy: ~
taxonomy_translation: ~
taxon: ~
taxon_translation: ~
sylius_locale:
driver: doctrine/orm
and
#app/config/parameters.yml
sylius.translation.default.mapping:
translatable:
field: translations
currentLocale: currentLocale
fallbackLocale: fallbackLocale
translation:
field: translatable
locale: locale
sylius.locale: %locale%
sylius.context.locale: %locale%
maybe this will shorten the process for someone else..
Please check https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Resources/config/app/sylius.yml#L239-L247.
I gues you should have similar section in your config.

Resources