php - Symfony2 - The class 'X' was not found in the chain configured namespaces -
i've been searching forever solve problem. can't find solution.
i error message when try open homepage:
uncaught exception 'doctrine\common\persistence\mapping\mappingexception' message 'the class 'test\bundle\userbundle\entity\user' not found in chain configured namespaces ' in...
the weird thing when have following url:
but when run on url don't error , page being displayed correctly:
my configuration looks (config.yml):
# doctrine configuration dbal: default_connection: default connections: default: driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: utf8 test: driver: "%database_driver2%" host: "%database_host2%" port: "%database_port2%" dbname: "%database_name2%" user: "%database_user2%" password: "%database_password2%" charset: utf8 orm: default_entity_manager: default entity_managers: default: connection: default mappings: testuserbundle: type: annotation
and call doctrine in custom service this:
public function __construct(entitymanager $em) { $repositiory = $em->getrepository('test\bundle\userbundle\entity\user'); $this->user = $repositiory->find($_server['auth_user']); }
my symfony application running on iis webserver.
do guys know made mistake?
mapping name testuserbundle
path test\bundle\user\bundle
, shouldn't named testbundleuserbundle
instead? also, mappings
, auto_generate_proxy_classes
set true
in dev mode might explain why it's working there , not in prod.
you might want checkout documentation (symfony 2.7) shows how should configuring mappings depending on case.
custom mapping entities in bundle
doctrine: # ... orm: # ... auto_mapping: true mappings: # ... appbundle: type: xml dir: someresources/config/doctrine
mapping entities outside of bundle
doctrine: # ... orm: # ... mappings: # ... someentitynamespace: type: annotation dir: "%kernel.root_dir%/../src/entity" is_bundle: false prefix: app\entity alias: app
last, not least, clear cache directory after applying changes config.yml
or files in app/config/
directory.
as mentioned in comments: need temporarily stop php processes might using prod directory (i.e. if you've ran console server:run) , try again. if doesn't it, try this
Comments
Post a Comment