cannot load Twig template (Symfony 2.8.8) - symfony

So I have the folder structure below:
According to the Symfony manual (click here), I should be able to load my Twig template but Symfony cannot find it.
Any ideas what I could be doing wrong? Thank you.
codes I've tried
return $this->render(
"AppBundle:DisplayForm.html.twig"
, array(
"form" => $form->createView()
);
return $this->render(
"DisplayForm.html.twig"
, array(
"form" => $form->createView()
)
);
Contents of my app/AppKernel.php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
contents of app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
assetic:
debug: '%kernel.debug%'
use_controller: '%kernel.debug%'
filters:
cssrewrite: ~

Because you are storing the template inside the bundle, you also have to reference the directory within the views - in this case, a 'null' directory.
AppBundle::DisplayForm.html.twig
Note the :: for the directory.
If you moved the entire AppBundle/Resources/views/ directory to app/Resources/views/ then you would be able to reference them much as a plain subdirectory:
Referencing templates stored in:
app/Resources/views/ | AcmeDemoBundle/Resources/views
----------------------------- | -------------------------------
index.html.twig | AcmeDemoBundle::index.html.twig
Default/subdir/index.html.twig | AcmeDemoBundle:Default:subdir/index.html.twig
Default/subdir/index.html.twig | AcmeDemoBundle:Default/subdir:index.html.twig

Probably you have forgotten an # symbol:
return $this->render(
"#AppBundle/DisplayForm.html.twig", [
"form" => $form->createView(
]
);

Related

PHP Fatal error: Uncaught exception 'Symfony\Component\Yaml\Exception\ParseException'

I have this bug when I use symfony 2.8, bug in config.yml maybe , help me please for resolve this problem and thanks advanced
FileLoaderLoadException in FileLoader.php line 133:
The file "/var/www/html/authenti/app/config/config.yml" does not contain valid YAML in /var/www/html/authenti/app/config/config.yml (which is being imported from "/var/www/html/authenti/app/config/config_dev.yml").
code config.yml:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ['%locale%'] }
secret: '%secret%'
router:
resource: '%kernel.root_dir%/config/routing.yml'
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: '%locale%'
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: '%kernel.root_dir%/data/data.db3'
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: '%database_path%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
imports:
// ...
- { resource: security.yml }
// ...
framework:
// ...
csrf_protection: ~
form: ~
session:
handler_id: ~
// ...
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
lexik_jwt_authentication:
private_key_path: %jwt_private_key_path%
public_key_path: %jwt_public_key_path%
pass_phrase: %jwt_key_pass_phrase%
token_ttl: %jwt_token_ttl%
// ...
dunglas_api:
title: "%api_name%"
description: "%api_description%"
enable_fos_user: true
nelmio_cors:
defaults:
allow_origin: ["%cors_allow_origin%"]
allow_methods: ["POST", "PUT", "GET", "DELETE", "OPTIONS"]
allow_headers: ["content-type", "authorization"]
expose_headers: ["link"]
max_age: 3600
paths:
'^/': ~
routing.yml:
app:
resource: '#AppBundle/Controller/'
type: annotation
api:
resource: "."
type: "api"
prefix: "/api"
api_login_check:
path: "/login_check"
parameters.yml.dist:
# This file is a "template" of what your parameters.yml file should look like
# Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
parameters:
database_host: 127.0.0.1
database_port: ~
database_name: symfony
database_user: root
database_password: ~
# You should uncomment this if you want to use pdo_sqlite
#database_path: "%kernel.root_dir%/data.db3"
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: ~
mailer_password: ~
jwt_private_key_path: %kernel.root_dir%/var/jwt/private.pem
jwt_public_key_path: %kernel.root_dir%/var/jwt/public.pem
jwt_key_pass_phrase : 'test'
jwt_token_ttl: 86400
cors_allow_origin: http://localhost:9000
api_name: Your API name
api_description: The full description of your API
# A secret key that's used to generate certain security-related tokens
secret: ThisTokenIsNotSoSecretChangeIt
try to indent well, I seen this for example to fix:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
Corrected:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }

Sonata User Advanced Configuration

I am trying to configure the advanced configuration of the SonataUser Bundle(https://sonata-project.org/bundles/user/3-x/doc/reference/advanced_configuration.html).
After following the documentation I get the following errors on installing assets:
[Symfony\Component\Config\Exception\FileLoaderLoadException]
There is no extension able to load the configuration for "jms_serializer" (in /var/www/html/SonataProject/app/config/config.yml). Looked for
namespace "jms_serializer", found "framework", "security", "twig", "monolog", "swiftmailer", "doctrine", "sensio_framework_extra", "fos_use
r", "sonata_core", "sonata_block", "knp_menu", "sonata_doctrine_orm_admin", "sonata_admin", "sonata_easy_extends", "sonata_user", "debug", "
web_profiler", "sensio_distribution" in /var/www/html/SonataProject/app/config/config.yml (which is being imported from "/var/www/html/Sonat
aProject/app/config/config_dev.yml").
After I comment out jms_serializer configuration, I get another error:
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "sonata_user.profile.dashboard.blocks.position". Expected array, but got string
Here is my config.yml:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
types:
json: Sonata\Doctrine\Types\JsonType
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
# naming_strategy: doctrine.orm.naming_strategy.underscore
# auto_mapping: true
entity_managers:
default:
mappings:
ApplicationSonataUserBundle: ~
SonataUserBundle: ~
FOSUserBundle: ~
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
#FOSUser Configuration
fos_user:
db_driver: orm
firewall_name: main
user_class: Application\Sonata\UserBundle\Entity\User
group:
group_class: Application\Sonata\UserBundle\Entity\Group
group_manager: sonata.user.orm.group_manager
profile:
# Authentication Form
form:
type: fos_user_profile
handler: fos_user.profile.form.handler.default
name: fos_user_profile_form
validation_groups: [Authentication]
service:
user_manager: sonata.user.orm.user_manager
#SonataUser
sonata_user:
security_acl: false
manager_type: orm
table:
user_group: "my_custom_user_group_association_table_name"
impersonating:
route: page_slug
parameters: { path: / }
class:
user: Sonata\UserBundle\Entity\User
group: Sonata\UserBundle\Entity\Group
admin: # Admin Classes
user:
class: Sonata\UserBundle\Admin\Entity\UserAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
group:
class: Sonata\UserBundle\Admin\Entity\GroupAdmin
controller: SonataAdminBundle:CRUD
translation: SonataUserBundle
profile:
# As in SonataAdminBundle's dashboard
dashboard:
groups:
# Prototype
id:
label: ~
label_catalogue: ~
items: []
item_adds: []
roles: []
blocks:
type: ~
settings:
# Prototype
id: []
position: right
register:
# You may customize the registration forms over here
form:
type: sonata_user_registration
handler: sonata.user.registration.form.handler.default
name: sonata_user_registration_form
validation_groups:
# Defaults:
- Registration
- Default
# This allows you to specify where you want your user redirected once he activated his account
confirm:
redirect:
# Set it to false to disable redirection
route: 'sonata_user_profile_show'
route_parameters: ~
# Customize user portal menu by setting links
menu:
- { route: 'sonata_user_profile_edit', label: 'link_edit_profile', domain: 'SonataUserBundle'}
- { route: 'sonata_user_profile_edit_authentication', label: 'link_edit_authentication', domain: 'SonataUserBundle'}
# Profile Form (firstname, lastname, etc ...)
form:
type: sonata_user_profile
handler: sonata.user.profile.form.handler.default
name: sonata_user_profile_form
validation_groups: [Profile]
# override FOSUser default serialization
jms_serializer:
metadata:
directories:
- { path: %kernel.root_dir%/../vendor/sonata-project/user-bundle/Sonata/UserBundle/Resources/config/serializer/FOSUserBundle, namespace_prefix: 'FOS\UserBundle' }
#SonataAdmin
sonata_block:
default_contexts: [cms]
blocks:
# enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
sonata.block.service.text:
sonata.block.service.rss:
Any ideas??
EDIT:
For the second error I tried editing the sonata_user.profile.dashboard.blocks as follows:
blocks:
type: ~
settings:
position: right
# Prototype
id: []
I am not sure if this is correct configuration but the error goes away.
Awaiting response!
Look at the doc the position is indented differently :
blocks:
type: ~
settings:
# Prototype
id: []
position: right
In yours, position is just under the id... Might be that

Symfony 2.5.5 & FOSUserBundle: the class ... was not found in the chain configured namespaces

Recently, I started working with Symfony2. Now I want to add a user management engine to my site.
But I'm facing a problem. This is what I'm doing:
In terms of creating/installing a basic Symfony2 project:
$ composer create-project symfony/framework-standard-edition path/ "2.5.*"
$ mv path/* ./
$ rm -r path/
Ok, so much for Symfony 2.5.5. Next, download the FOSUserBundle and create a custom bundle:
$ composer require friendsofsymfony/user-bundle '~2.0#dev'
$ php app/console generate:bundle --namespace=Meiblorn/CoreBundle --format=yml
Create the User class in the Meiblorn\CoreBundle\Framework\Domain namespace
/**
* User: Meiblorn
* Date: 15/10/14
* Time: 20:17
*/
namespace Meiblorn\CoreBundle\Framework\Domain;
use FOS\UserBundle\Model\User as FOSUserBundleUser;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
* #ORM\Table(
* name = "users"
* )
*/
class User extends FOSUserBundleUser {
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct() {
parent::__construct();
// your own logic
}
}
?>
Configure the security.yml and config.yml. Finally, I got this:
AppKernel.php
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Meiblorn\CoreBundle\MeiblornCoreBundle(),
);
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: prod
user_class: Meiblorn\CoreBundle\Framework\Domain\User
security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
prod:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
THIS IS THE PROBLEM
In browser: http://localhost/test.meiblorn.com/web/app_dev.php/
MappingException: The class 'Meiblorn\CoreBundle\Framework\Domain\User' was not found in the chain configured namespaces FOS\UserBundle\Model
in /Library/WebServer/Documents/test.meiblorn.com/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php line 37
at MappingException::classNotFoundInNamespaces('Meiblorn\CoreBundle\Framework\Domain\User', array('FOS\UserBundle\Model')) in /Library/WebServer/Documents/test.meiblorn.com/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php line 113
at MappingDriverChain->loadMetadataForClass('Meiblorn\CoreBundle\Framework\Domain\User', object(ClassMetadata)) in /Library/WebServer/Documents/test.meiblorn.com/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php line 117
at ClassMetadataFactory->doLoadMetadata(object(ClassMetadata), object(ClassMetadata), false, array()) in /Library/WebServer/Documents/test.meiblorn.com/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php line 318
Also Doctrine doesn't create tables for this mapping when calling doctrine:schema:update
Please, help me to fix this exception
UPDATE! How to fix
Final configuration for my namespace
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: false
mappings:
FOSUserBundle: ~
MeiblornCoreBundle:
type: annotation
dir: %kernel.root_dir%/../src/Meiblorn/CoreBundle/Framework/Entity
prefix: Meiblorn\CoreBundle\Framework\Entity
# alias: MyModels
# is_bundle: true
First you need to configure psr-4 autoload in your composer.js, for example
"autoload": {
"psr-4": {
"Meiblorn\\CoreBundle\\": "src/Meiblorn/CoreBundle/"
}
},
Then call composer dumpautoload.
Secondly, I believe Doctrine expects the entities to live in a folder Entity/, so try to move you model: src/Meiblorn/CoreBundle/Framework/Domain/User.php to src/Meiblorn/CoreBundle/Entity/User.php or How do I change symfony 2 doctrine mapper to use my custom directory instead of my Entity Directory under the bundle

A2lixTranslationFormBundle with Stof DoctrineExtensionsBundle doesnt Show Any Tab

I'm new to Symfony and Sonata. After following the instructions i installed Translatable, but i dont get any Tab in the form.
Composer.json
"stof/doctrine-extensions-bundle": "1.1.x-dev",
"a2lix/translation-form-bundle": "2.x-dev"
config.yml
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
mappings:
gedmo_translatable:
type: annotation
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
is_bundle: false
stof_doctrine_extensions:
default_locale: "%locale%"
orm:
default:
translatable: true
a2lix_translation_form:
locales: [es, pr] # [1]
default_required: true # [2]
manager_registry: doctrine # [3]
templating: "A2lixTranslationFormBundle::default.html.twig" # [4]
Sonata AdminClass
/**
* #param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('descripcion')
->add('unidadMedida')
->add('translations', 'a2lix_translations')
;
}
I had so much trouble trying to use those 2 bundles that I switched to using only a2lix bundles and it worked like a charm for me...
This is what I am using now (sf 2.4)
"a2lix/i18n-doctrine-bundle": "dev-master",
"a2lix/translation-form-bundle": "2.*#dev",

symfony+Mapping error

I am implementing the FOSUser module in my symfony i have created and configure all file as the tutorial.here is my config.yml file for mapping.
namespace Acme\UserBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
class User extends BaseUser
{
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
it is showing the following error ..
MappingException: The class 'Acme\UserBundle\Entity\User'
was not found in the chain configured namespaces FOS\UserBundle\Entity
here is my config.yml file where i mention the autoloding. still it not working.
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
#esi: ~
#translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: %kernel.debug%
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: %kernel.root_dir%/Resources/java/compiler.jar
#yui_css:
# jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: main
user_class: Acme\UserBundle\Entity\User
Ok, this should be easy. You need to, either enable auto_mapping in your config.yml or to manually specify "AcmeUserBundle: ~" there:
1) with auto_mapping
doctrine:
orm:
auto_mapping: true
2) without auto_mapping
doctrine:
orm:
mappings:
AcmeUserBundle: ~
Notice that if you are having multiple entity managers you won't be able to use auto_mapping feature.
Hope this helps!
It is also can help:
Add into your app/AppKernel.php:
...
new Acme\UserBundle\AcmeUserBundle(),
...
Add the following line to your app/AppKernel.php file's bundle array:
new FOS\UserBundle\FOSUserBundle()
This is to register that namespace for Symfony.
solucion for me:
change in ../Entity/User.php
namespace Acme\UserBundle\Entity; with namespace Acme\Bundle\UserBundle\Entity;
and in app/config.yml change
user_class: Acme\UserBundle\Entity\User with
user_class: Acme\Bundle\UserBundle\Entity\User
Regards, Amic

Resources