Unknown Entity namespace alias 'PirastruFormBuilderBundle' - symfony

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,

Related

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.

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.

How to define/pass the entity manager for sonata-admin

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.

Getting troubles when trying to install FOSUserBundle to Symfony2

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

Symfony2 + doctrine2: Switch to metadata driver "yml"

a short question: How to switch to the another metadata driver than annotation. How to set the metadata driver "yml" in the config.yml?
I`ve searched google and the symfony2 docu, but didnt find anything :(
thanks
You should be able to do that with the doctrine:mapping:convert command
php app/console doctrine:mapping:convert --force yml ./src/
Double check all the options available before you run the command, though
php app/console help doctrine:mapping:convert
I realize this is an older question but you can explicitly require that doctrine use the yml driver for meta data like this:
doctrine:
orm:
entity_managers:
mappings:
MyBundleName:
type: yml
dir: path/to/ymlmetadata
Be aware that if you use this configuration style then you have to put the "defaults" config node under entity_managers instead of its usual location.

Resources