<legend id='LqO48'><style id='LqO48'><dir id='LqO48'><q id='LqO48'></q></dir></style></legend>

      <bdo id='LqO48'></bdo><ul id='LqO48'></ul>

    <small id='LqO48'></small><noframes id='LqO48'>

  1. <tfoot id='LqO48'></tfoot>
    <i id='LqO48'><tr id='LqO48'><dt id='LqO48'><q id='LqO48'><span id='LqO48'><b id='LqO48'><form id='LqO48'><ins id='LqO48'></ins><ul id='LqO48'></ul><sub id='LqO48'></sub></form><legend id='LqO48'></legend><bdo id='LqO48'><pre id='LqO48'><center id='LqO48'></center></pre></bdo></b><th id='LqO48'></th></span></q></dt></tr></i><div id='LqO48'><tfoot id='LqO48'></tfoot><dl id='LqO48'><fieldset id='LqO48'></fieldset></dl></div>

      Symfony2 - 在链配置的命名空间中找不到类“X"

      Symfony2 - The class #39;X#39; was not found in the chain configured namespaces(Symfony2 - 在链配置的命名空间中找不到类“X)
        <tbody id='gdUu7'></tbody>
      <tfoot id='gdUu7'></tfoot>

        <small id='gdUu7'></small><noframes id='gdUu7'>

          <legend id='gdUu7'><style id='gdUu7'><dir id='gdUu7'><q id='gdUu7'></q></dir></style></legend>
          <i id='gdUu7'><tr id='gdUu7'><dt id='gdUu7'><q id='gdUu7'><span id='gdUu7'><b id='gdUu7'><form id='gdUu7'><ins id='gdUu7'></ins><ul id='gdUu7'></ul><sub id='gdUu7'></sub></form><legend id='gdUu7'></legend><bdo id='gdUu7'><pre id='gdUu7'><center id='gdUu7'></center></pre></bdo></b><th id='gdUu7'></th></span></q></dt></tr></i><div id='gdUu7'><tfoot id='gdUu7'></tfoot><dl id='gdUu7'><fieldset id='gdUu7'></fieldset></dl></div>

            • <bdo id='gdUu7'></bdo><ul id='gdUu7'></ul>
                本文介绍了Symfony2 - 在链配置的命名空间中找不到类“X"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我一直在寻找解决问题的方法.但我找不到任何解决方案.

                I've been searching forever to solve my problem. But I can't find any solution.

                当我尝试打开主页时,总是收到此错误消息:

                I always get this error message when I try to open the homepage:

                未捕获的异常 'DoctrineCommonPersistenceMappingMappingException' 带有消息 'The class 'TestBundleUserBundleEntityUser' is not found in the chain configured namespaces' in...

                奇怪的是,我只有在我有以下 URL 时才能得到它:

                The weird thing is that I only get it when I have following URL:

                http://localhost/

                但是当我在这个 URL 上运行它时,我没有收到任何错误,并且我的页面正在正确显示:

                But when I run it on this URL I don't get any error and my page is being displayed correctly:

                http://localhost/app_dev.php

                我的配置看起来像这样(config.yml):

                My Configuration looks like this (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
                

                我在我的自定义服务中这样调用 Doctrine:

                And I call Doctrine in my custom service like this:

                public function __construct(EntityManager $em)
                {
                    $repositiory = $em->getRepository('TestBundleUserBundleEntityUser');
                    $this->user = $repositiory->find($_SERVER['AUTH_USER']);
                }
                

                我的 Symfony 应用程序正在 IIS Web 服务器上运行.

                My Symfony Application is running on an IIS Webserver.

                你们知道我哪里做错了吗?

                Do you guys know where I made a mistake?

                推荐答案

                映射名称是 TestUserBundle 但路径是 TestBundleUserBundle,不应该它被命名为 TestBundleUserBundle 吗?此外,通常 mappingsauto_generate_proxy_classes 在开发模式下设置为 true,这可能解释了为什么它在那里工作而不是在 prod 中工作.

                Mapping name is TestUserBundle but the path is TestBundleUserBundle, shouldn't it be named TestBundleUserBundle instead? Also, usually the mappings and auto_generate_proxy_classes are set to true in dev mode which might explain why it's working there and not in prod.

                您可能想查看 documentation (Symfony 2.7) 它显示了你应该如何根据你的情况来配置映射.

                You might want to checkout the documentation (Symfony 2.7) which shows how exactly you should be configuring the mappings depending on your case.

                doctrine:
                    # ...
                    orm:
                        # ...
                        auto_mapping: true
                        mappings:
                            # ...
                            AppBundle:
                                type: xml
                                dir: SomeResources/config/doctrine
                

                映射包外的实体

                doctrine:
                    # ...
                    orm:
                        # ...
                        mappings:
                            # ...
                            SomeEntityNamespace:
                                type: annotation
                                dir: "%kernel.root_dir%/../src/Entity"
                                is_bundle: false
                                prefix: AppEntity
                                alias: App
                

                最后但同样重要的是,在将更改应用到 config.ymlapp/config/ 目录中的文件后,请务必清除缓存目录.

                Last, but not least, always clear your cache directory after applying changes to the config.yml or files in the app/config/ directory.

                正如评论中提到的:您需要暂时停止任何可能正在使用 prod 目录的 PHP 进程(即,如果您已经运行了控制台服务器:运行)并重试.如果还不行,试试 这个

                As mentioned in the comments: You need to temporarily stop any PHP processes that might be using the prod directory (i.e. if you've ran console server:run) and try again. If that doesn't do it, try this

                这篇关于Symfony2 - 在链配置的命名空间中找不到类“X"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Converting between timezones in PHP(在 PHP 中的时区之间转换)
                PHP - strtotime, specify timezone(PHP - strtotime,指定时区)
                Get current date, given a timezone in PHP?(获取当前日期,给定 PHP 中的时区?)
                List of US Time Zones for PHP to use?(PHP 使用的美国时区列表?)
                How to detect Ambiguous and Invalid DateTime in PHP?(如何在 PHP 中检测不明确和无效的 DateTime?)
                How to update timezonedb in PHP (updating timezones info)?(如何在 PHP 中更新 timezonedb(更新时区信息)?)
                  <tbody id='2ZbQy'></tbody>

                <small id='2ZbQy'></small><noframes id='2ZbQy'>

                        <i id='2ZbQy'><tr id='2ZbQy'><dt id='2ZbQy'><q id='2ZbQy'><span id='2ZbQy'><b id='2ZbQy'><form id='2ZbQy'><ins id='2ZbQy'></ins><ul id='2ZbQy'></ul><sub id='2ZbQy'></sub></form><legend id='2ZbQy'></legend><bdo id='2ZbQy'><pre id='2ZbQy'><center id='2ZbQy'></center></pre></bdo></b><th id='2ZbQy'></th></span></q></dt></tr></i><div id='2ZbQy'><tfoot id='2ZbQy'></tfoot><dl id='2ZbQy'><fieldset id='2ZbQy'></fieldset></dl></div>
                      1. <tfoot id='2ZbQy'></tfoot>

                          <bdo id='2ZbQy'></bdo><ul id='2ZbQy'></ul>
                        • <legend id='2ZbQy'><style id='2ZbQy'><dir id='2ZbQy'><q id='2ZbQy'></q></dir></style></legend>