我的Symfony4应用程序在开发环境中工作正常,但在生产中不能登录(使用fosuserbundle(。在生产中启用调试和profiler工具栏后(它没有写任何日志(,我发现了错误
在该类中找不到类'App Entity fintelitility user user' 链配置的名称空间fos userBundle model
在链中配置的名称空间
中找不到该类我已经清除了缓存,并且已经检查了学说的映射信息
php bin/console doctrine:mapping:info --env=prod
Found 2 mapped entities:
[OK] FOSUserBundleModelGroup
[OK] FOSUserBundleModelUser
wwwfintel@fnt-srvweb01:~/s4fgel$ php bin/console doctrine:mapping:info --env=dev
Found 5 mapped entities:
[OK] AppEntityFintelUtilityQuoteOfTheDay
[OK] AppEntityFintelUtilityUserGroup
[OK] AppEntityFintelUtilityUserUser
[OK] FOSUserBundleModelGroup
[OK] FOSUserBundleModelUser
我不知道如何映射缺少的三个实体。
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: 'AppTypeDateTimeKeyType'
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: 'AppEntityFintelUtility'
is_bundle: false
when没有config/packages/dev/doctrine.yaml,但prod config/packages/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: SymfonyComponentCacheDoctrineProvider
public: false
arguments:
- '@doctrine.result_cache_pool'
doctrine.system_cache_provider:
class: SymfonyComponentCacheDoctrineProvider
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缓存:热身-env = prod -no-debug,但它没有帮助
有什么想法吗?
编辑
我已经将" mssql_fgel_utility" Entity Manager更改为"默认",它适用于产品,但则不适用于dev
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
我已将" mssql_fgel_utility" Entity Manager更改为"默认",它工作
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
您写的:
我已经清除了缓存,并且已经检查了学说的映射信息
是Symfony Cache还是Doctrine Cache?如果不是学说缓存,请清除它并尝试命令php bin/console do:sc:va
检查映射,并检查数据库是否与映射同步,并在情况下进行php bin/console do:sc:up --force --env=prod
并不同步。
您必须将"mssql_fgel_utility"
Entity Manager更改为"default"
和DELETE "default_entity_manager: mssql_fgel_utility"
,它将适用于dev
和prod
。