mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Problem in prod mode - MappingException #7125
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @maouache on GitHub (Mar 24, 2023).
Bug Report
Hello,
I had a weird problem, I created a symfony 6.2.7 project with the doctrine version here is the info:
I created my Person entity with
php bin/console make:entitywhich generated Personne.php (class Personne) and in doctrine table personne of course with the migration and all the steps.When I wanted to switch to prod mode: I got this error message:
It looks like doctrine is looking for a class called
'App\\Entity\\personne'when it's actually'App\\Entity\\Personne'.Temporary solution
For the moment I diverted that with a duplication of the file Personne.php and personne.php so that it works in both prod and dev mode. of in dev mode you don't need the duplication file.
Used but not working
I tried all the cache option delete:
The links of symfony for the deployment here they are all:
https://symfony.com/doc/current/deployment.html.
https://symfony.com/doc/3.4/setup/file_permissions.html
https://github.com/sonata-project/SonataAdminBundle/issues/5021
Where the error comes from ?
I think the problem comes from doctrine which converts 'Personne' into 'personne' when doctrine is in prod mode, so it triggers MappingException with the message
"App\Entity' does not exist"because there is not file calledpersonne.phpbutPersonne.phpexist.@greg0ire commented on GitHub (Mar 24, 2023):
I don't know why Doctrine would do this. Things I would do if I were you:
composer outdated@maouache commented on GitHub (Mar 24, 2023):
Composer Outdated
Stack Trace il give you my last prod.log
Use a debugger based on what I see in the stack trace
How can i use a debugger in prod because he show me directly 500 error message, can you give me more information ? do you mean prod in with debug = true ?
@greg0ire commented on GitHub (Mar 24, 2023):
That's not a stack trace.
Use XDebug with a breakpoint, in dev, in prod mode.
@mpdude commented on GitHub (Mar 25, 2023):
Do a case-sensitive search with you IDE for
personne, maybe you wrote it that way somewhere?@maouache commented on GitHub (Mar 27, 2023):
Before using the xdebug and doing what you asked me to do we'll do it step by step:
To explain you well what happens:
I have these routes:
I notice that when the debug is activated it finds all the controllers, as well as the routes, but without the debug active I have this error
I need help how I can upgrade these packages with the command "compose outdated":
I have tried composing update and composing upgrade I can't get them up to date.
@greg0ire commented on GitHub (Mar 27, 2023):
It's
composer, notcomposing, that's why it doesn't work :trollface: But you don't need to update those (and might not even be able to in the case ofdoctrine/lexer).Now that's cleared up, I'm a bit surprised at the design of the error page… In Symfony, there used to be a stack trace tab, as shown here: https://symfony.com/doc/current/contributing/code/stack_trace.html#getting-stack-traces-with-symfony
@maouache commented on GitHub (Mar 27, 2023):
sorry i mean composer update or upgrade not updating doctrine/instantiator and doctrine/lexer.
yeah me too it's new design for symfony 6.2.7, i didn't find Stack Traces when i got the error in ('APP_ENV' => 'dev' && 'APP_DEBUG' => '0')
@raphael-geffroy commented on GitHub (Mar 27, 2023):
With APP_DEBUG at false you won't see a stacktrace I don't think it's design related. Are you using sonata or any genericity between controllers and entities ?
@maouache commented on GitHub (Mar 27, 2023):
I don't know what sonata is, but I made it simple with symfony,
here is my code:
Created by php/bin console make:entity + doctrine:migration + doctrine:migrate
Personne.php
PersonneController.php
@raphael-geffroy commented on GitHub (Mar 29, 2023):
Can you open a repository on github so I can have a look and try to replicate ?
@maouache commented on GitHub (Mar 29, 2023):
No I can't. I asked my superior to fix the problem you asked me to open a repository on github, so that you help me to fix the problem, he refused, it's a company project they want to keep private. for the moment the duplication of the file Personne.php (with personne.php in lower case) it's enough for him.