0
votes

On localhost works all fine. But when uploaded to the server throws this error. What could be wrong?

Uncaught exception 'Doctrine\Common\Persistence\Mapping\MappingException' with message 'The class 'Acme\DemoBundle\Entity\User' was not found in the chain configured namespaces FOS\UserBundle\Entity, Acme\BazaBundle\Entity, FOS\UserBundle\Model'

http://baza.sysit.com.ua/web/

config.yml:

 fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Acme\DemoBundle\Entity\User
2
that code snippet is wrong. Yaml is indentation based, it can't make any sense of the snippet you posted here.Wouter J

2 Answers

0
votes

This is because you are referencing a class within a bundle that is not registered. You probably removed the initialization for the AcmeDemoBundle in the AppKernel.php but it still references it in your FOSUser config.

You will need to create a User entity for your bundle and reference it in user_class parameter under fos_user, or if you are using the AcmeDemoBundle to hold your User entity, then just re-initialize it in your AppKernel.php

0
votes

The Acme bundle is by default only available in development and test environments. As long as you working on your localhost, it's not a problem. You are probably working in the development environment and in your app_kernel.php Acme\DemoBundle is set to initialize only when the environment is dev or test. So it's working just fine.

On your server you're not accessing your site through the localhost. that means the development environment is not available. Your working on a production environment. Like I explained above, the production environment has no Acme\DemoBundle initialized, so it can't find your user entity.

There are 2 possibilities:

  • go to your app-kernel.php: find the line "$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();" and delete it. Then add the following line ("new Acme\DemoBundle\AcmeDemoBundle(),") to the first array of bundles.

  • create a new bundle and add it to your app.kernel.php and put your User class in that bundle.

If you're just creating a website for personal use, the first option may be the quickest and best option, but if you want your bundles to be named nice, you should use the last. good luck