我的Symfony4应用程序在开发环境中工作正常,但在生产中没有,我无法登录(使用FosUserBundle)。在生产中启用调试和分析器工具栏后(因为它没有写任何日志)我发现了错误
班级' App \ Entity \ FintelUtility \ User \ User'在...中找不到 链配置的命名空间FOS \ UserBundle \ Model
在链配置的命名空间中找不到该类
我清除了缓存,并且我已经检查了教条的映射信息
php bin/console doctrine:mapping:info --env=prod
Found 2 mapped entities:
[OK] FOS\UserBundle\Model\Group
[OK] FOS\UserBundle\Model\User
wwwfintel@fnt-srvweb01:~/s4fgel$ php bin/console doctrine:mapping:info --env=dev
Found 5 mapped entities:
[OK] App\Entity\FintelUtility\QuoteOfTheDay
[OK] App\Entity\FintelUtility\User\Group
[OK] App\Entity\FintelUtility\User\User
[OK] FOS\UserBundle\Model\Group
[OK] FOS\UserBundle\Model\User
我不知道如何映射那三个缺失的实体。
config / packages / doctrine.yaml
# Doctrine Configuration
doctrine:
dbal:
default_connection: mssql_fgel_utility
connections:
mssql_fgel_utility:
driver: ~
driver_class: "%fgelutil_database_driver_class%"
host: "%fgelutil_database_host%"
dbname: "%fgelutil_database_name%"
user: "%fgelutil_database_user%"
password: "%fgelutil_database_password%"
types:
datetime_key: 'App\Type\DateTimeKeyType'
orm:
default_entity_manager: mssql_fgel_utility
entity_managers:
#################################
# Update schema only with this em
#################################
mssql_fgel_utility:
connection: mssql_fgel_utility
mappings:
FintelUtility:
type: "annotation"
# The directory for entity (relative to bundle path)
dir: '%kernel.project_dir%/src/Entity/FintelUtility'
prefix: 'App\Entity\FintelUtility'
is_bundle: false
没有配置/包/ dev / doctrine.yaml但是prod 的配置/包/ PROD / doctrine.yaml
doctrine:
orm:
metadata_cache_driver:
type: service
id: doctrine.system_cache_provider
query_cache_driver:
type: service
id: doctrine.system_cache_provider
result_cache_driver:
type: service
id: doctrine.result_cache_provider
services:
doctrine.result_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.result_cache_pool'
doctrine.system_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.system_cache_pool'
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system
我也尝试了php bin / console cache:warmup --env = prod --no-debug但它没有帮助
有什么想法吗?
修改
我已经改变了" mssql_fgel_utility"实体经理到"默认"并且它适用于产品,但然后它不适用于开发
orm:
default_entity_manager: mssql_fgel_utility
entity_managers:
#################################
# Update schema only with this em
#################################
# THIS WAS WRONG EVEN IF I DON'T KNOW WHY
# mssql_fgel_utility:
#################################
default: #changed to this
答案 0 :(得分:1)
我已将“mssql_fgel_utility”实体管理器更改为“默认”并且有效
orm:
default_entity_manager: default
entity_managers:
#################################
# Update schema only with this em
#################################
# THIS WAS WRONG EVEN IF I DON'T KNOW WHY
# mssql_fgel_utility:
#################################
default: #changed to this
答案 1 :(得分:0)
您写道:
我已经清除了缓存,并且我已经检查了教条的映射信息
是Symfony缓存还是Doctrine缓存?如果它不是Doctrine缓存,请清除它并尝试命令php bin/console do:sc:va
检查映射并检查数据库是否与映射同步,并在不同步的情况下生成php bin/console do:sc:up --force --env=prod
。
答案 2 :(得分:0)
您必须将"mssql_fgel_utility"
实体经理更改为"default"
并删除"default_entity_manager: mssql_fgel_utility"
,它才适用于dev
和prod
。