问题描述
我正在在Symfony2上开发一个网站,我想将FosuserBundle交往.我正在使用学说ORM用户类.我遵循安装步骤但是我得到了这个错误:
ClassNotFoundException in AppKernel.php line 21: Attempted to load class "FOSUserBundle" from namespace "FOS\UserBundle". Did you forget a "use" statement for another namespace?
appkernel.php:
public function registerBundles() { $bundles = array( ... new FOS\UserBundle\FOSUserBundle(), );
看起来正确放置:fosuserbundle.php位于 \ vendor \ friendsofsymfony \ userbundle
中,我认为名称空间是正确的:名称空间fos \ userBundle;
其他文件:
#config.yml
fos_user: db_driver: orm firewall_name: main user_class: REMERA\PlatformBundle\Entity\User
#routing.yml
fos_user: resource: "@FOSUserBundle/Resources/config/routing/all.xml"
#security.yml
security: encoders: FOS\UserBundle\Model\UserInterface: bcrypt role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: ROLE_ADMIN providers: fos_userbundle: id: fos_user.user_provider.username firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4 logout: true anonymous: true 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 }
我一直在尝试解决这个问题数小时,其他类似问题的答案不能解决我的错误.我想念什么吗? 预先感谢.
推荐答案
如何解决此问题:
尝试先清除缓存.然后,如果它仍然不起作用,则作曲家删除,作曲家需要并再次更新作曲家. - brewal
其他推荐答案
当您尝试清除缓存时,但是您不应使用--no-warmup选项,这将确保您的缓存重新生成,并且缓存不仅可以加热.我认为这可以帮助您:
php app/console cache:clear --env=prod --no-warmup
或
php app/console cache:clear --env=dev --no-warmup
问题描述
I'm developping a website on Symfony2, I want to intergrate FOSUserBundle. I am using Doctrine ORM User class. I've followed the installation steps but I got this error:
ClassNotFoundException in AppKernel.php line 21: Attempted to load class "FOSUserBundle" from namespace "FOS\UserBundle". Did you forget a "use" statement for another namespace?
AppKernel.php:
public function registerBundles() { $bundles = array( ... new FOS\UserBundle\FOSUserBundle(), );
It looks correctly placed: FOSUserBundle.php is located in \vendor\friendsofsymfony\userbundle
And the namespace is correct I think: namespace FOS\UserBundle;
Other files:
#config.yml
fos_user: db_driver: orm firewall_name: main user_class: REMERA\PlatformBundle\Entity\User
#routing.yml
fos_user: resource: "@FOSUserBundle/Resources/config/routing/all.xml"
#security.yml
security: encoders: FOS\UserBundle\Model\UserInterface: bcrypt role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: ROLE_ADMIN providers: fos_userbundle: id: fos_user.user_provider.username firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4 logout: true anonymous: true 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 }
I've been trying to solve this for hours, answers on other similar questions don't resolve my error. Am I missing something? Thanks in advance.
推荐答案
How this was solved:
try to clear the cache first. Then if it is still not working, composer remove, composer require and composer update again. – Brewal
其他推荐答案
When you try to clear cache but its not getting cleared you should use --no-warmup option, this will make sure that you cache is re-generated and cache is not warmed up only. I think this can help you:
php app/console cache:clear --env=prod --no-warmup
or
php app/console cache:clear --env=dev --no-warmup