Symfony bundle registration - symfony

I am maintaining an app that registers bundles in two different place:
In app/AppKernel.php, in the $bundles array
In app/config/config.yml, under the bundles key
ie, in config.yml:
bundles:
# Defaults (all currently registered bundles):
- FrameworkBundle
- SecurityBundle
- TwigBundle
- MonologBundle
- SwiftmailerBundle
- DoctrineBundle
- AsseticBundle
- FOSUserBundle
Registering in AppKernel.php was usual for me, but where/why is the registration in the config.yml file used?

Related

Symfony 3.2.1 - bundle controllers in sub-directories

EDIT | I tried prefixing controllers class name with "Web" - no dice :(
According to everything I have read and previously experienced:
http://symfony.com/doc/current/best_practices/controllers.html
I should be able to move/organize controllers into sub-folders but now I cannot seem to get Symfony to cooperate:
AppBundle/Controller
- MemberController.php
- DefaultController.php
Works fine - but if I move
AppBundle/Controller
/web/MemberController
- DefaultController
Then clear the cache - I get the following error(s):
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Class AppBundle\Controller\MemberController does not exist in /var/www/project/src/AppBundle/Controller (which is being imported from "/var/www/project/app/config/routing.yml").
[ReflectionException]
Class AppBundle\Controller\MemberController does not exist
Of course it doesn't I moved it up down one directory into a sub-folder "web". What gives? My routing.yml is as simple as:
site:
resource: "#AppBundle/Controller"
type: annotation

The service "fos_user.group_manager" has a dependency on a non-existent service "fos_user.entity_manager"

I am using symfony 2.8 i want to configure sonata user bundle and fosUserbundle
beolw is my image link:
image
Try adding this in config.yml
fos_user:
service:
user_manager: fos_user.user_manager.default
You can check this official config reference: http://symfony.com/doc/current/bundles/FOSUserBundle/configuration_reference.html

EasyAdminBundle ReflectionException at create Backend section of install

Having an issue with the final stage of the setup of Easy Admin in a fresh Symfony 3 install,
at the "Your First Backend" : Creating the backend for those entities just require you to add the following configuration in the app/config/config.yml file:
# app/config/config.yml
easy_admin:
entities:
- AppBundle\Entity\Product
- AppBundle\Entity\Category
- AppBundle\Entity\User
When I do this I get error :
[ReflectionException] Class
AppBundle\Entity\Product does not exist
All the previous commands for setup installed without error, including installing the assets.
In documentation of EasyAdminBundle You have
Let's suppose that your Symfony application defines three Doctrine ORM entities called Product, Category and User.
In entities section you need to list already existing in your app Entities. If you don't have any - create it.
Docs: https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/getting-started/2-first-backend.md

Entity alias in new symfony 2.7 directory structure

after adapting to new recommended structure in Symfony 2.7 I'm not able to access entity alias through $em->getRepository('Bundle:Entity').
This is my directory structure:
MyBundle
- Component
- Catalog
- Model
Product.php
And my mapping definitition in config.yml:
mappings:
mybundle:
type: annotation
dir: %kernel.root_dir%/../src/mybundle/Component/Product/Model
prefix: MyBundle\Component\Product\Model
alias: ??? # I tried different things
What should I write in $em->getRepository('MyBundle:Product') instead of MyBundle:Product to succesfully accesing the entity?
If possible I would like to use default Symfony alias, so I don't need to specify an alias for every entity in config.yml
Actually I didn't need generate:bundle as it's not a real bundle but a namespace and a logical organization of files.
The solution is to specify the complete namespace in getRespository():
$em->getRepository('MyBundle\\Component\\Product\\Model\\CFGProduct)
Thanks

entity manager not defined in sonata bundle

I have integrated sonata admin bundle. I then integrate sonata news bundle successfully . Then I created a custom bundle. I want to configure this bundle as my CMS bundle using sonata bundle. I am able to display my CMS bundle in admin section but when I try to to edit or add new item I am getting an error:
No entity manager defined for class Fcse\CmsBundle\Entity\Book 500
Internal Server Error - RuntimeException
Book is my entity when i run command
app/console doctrine:schema:update --force
Book table is also not creating. Am I missing something in configuration?
my config file is large. i am posting the code of my cms bundle.
fcse_cms:
title: Sonata Project
link: http://local.demo
description: Cool bundles on top of Symfony2
salt: 'secureToken'
class:
book: Fcse\CmsBundle\Entity\Book
admin:
book:
class: Fcse\CmsBundle\Admin\BookAdmin
controller: SonataAdminBundle:CRUD
translation: CmsBundle
doctrine:
orm:
entity_managers:
default:
#metadata_cache_driver: apc
#query_cache_driver: apc
#result_cache_driver: apc
mappings:
FcseCmsBundle: ~
and i import this file in app/config.yml.

Resources