Problem in prod mode - MappingException #7124

Open
opened 2026-01-22 15:45:09 +01:00 by admin · 0 comments
Owner

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:

Composer.json file:

"doctrine/doctrine-bundle": "^2.7",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.13",

I created my Person entity with php bin/console make:entity which 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:


{ "message": "Uncaught PHP Exception Doctrine\Persistence\Mapping\MappingException: \"Class 'App\Entity\personne' does not exist" at /home/mohamed/Workspace/Symfony/cnfm/project/geco/vendor/doctrine/persistence/src/Persistence/Mapping/MappingException. php line 80", "context":{"exception":{"class": "Doctrine\Persistence\MappingException", "message": "Class 'App\Entity\personne' does not exist", "code":0, "file":"/home/mohamed/Workspace/Symfony/cnfm/project/geco/vendor/doctrine/persistence/src/Persistence/MappingException. php:80"}},"level":500,"level_name":"CRITICAL","channel":"request","datetime":"2023-03-24T15:29:59.022378+01:00","extra":{}}

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:

php bin/console doctrine:cache:clear-metadata --env=prod 
php bin/console cache:warmup --env=prod --no-debug
php bin/console doctrine:mapping:info --env=prod
php bin/console cache:clear --env=prod

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 called personne.php but Personne.php exist.

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: ``` Composer.json file: "doctrine/doctrine-bundle": "^2.7", "doctrine/doctrine-fixtures-bundle": "^3.4", "doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/orm": "^2.13", ``` I created my Person entity with `php bin/console make:entity` which 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: ``` { "message": "Uncaught PHP Exception Doctrine\Persistence\Mapping\MappingException: \"Class 'App\Entity\personne' does not exist" at /home/mohamed/Workspace/Symfony/cnfm/project/geco/vendor/doctrine/persistence/src/Persistence/Mapping/MappingException. php line 80", "context":{"exception":{"class": "Doctrine\Persistence\MappingException", "message": "Class 'App\Entity\personne' does not exist", "code":0, "file":"/home/mohamed/Workspace/Symfony/cnfm/project/geco/vendor/doctrine/persistence/src/Persistence/MappingException. php:80"}},"level":500,"level_name":"CRITICAL","channel":"request","datetime":"2023-03-24T15:29:59.022378+01:00","extra":{}} ``` 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: ``` php bin/console doctrine:cache:clear-metadata --env=prod php bin/console cache:warmup --env=prod --no-debug php bin/console doctrine:mapping:info --env=prod php bin/console cache:clear --env=prod ``` 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 called `personne.php` but `Personne.php` exist. <!-- Fill in the relevant information below to help triage your issue. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7124