PHPMaker version: 2026.15
Framework: Symfony / Doctrine ORM
Database: MariaDB
Problem
When generating a Symfony application, PHPMaker generates Doctrine entities for database views with composite primary keys. The generated PHP code contains multiple #[Id] attributes and also adds #[GeneratedValue] to the same fields.
For example, the generated entity contains code like this:
#[Id]
#[Column(name: 'id_a', type: 'integer')]
#[GeneratedValue]
private ?int $idA;
#[Id]
#[Column(name: 'id_b', type: 'bigint')]
#[GeneratedValue]
private ?string $idB;
When Symfony initializes Doctrine's metadata, the application fails with HTTP 500.
The exact exception message is:
Doctrine\ORM\Mapping\MappingException:
Single id is not allowed on composite primary key in entity
PHPMaker2026\<ProjectNamespace>\Db\Entity\<GeneratedViewEntity>
The exception is thrown from Doctrine's ClassMetadata::getSingleIdentifierFieldName() during metadata initialization. It can occur while Symfony is warming up the cache, before the requested page is executed.
Findings
Both fields are marked as primary keys in PHPMaker's Field Setup. However, the generated .pmp project file also contains the following settings for both fields:
FldIsPrimaryKey="1" FldAutoIncrement="1"
The corresponding columns in the MariaDB views do not have the AUTO_INCREMENT property. In information_schema.COLUMNS, EXTRA is empty and IS_GENERATED is NEVER.
Nevertheless, PHPMaker generates #[GeneratedValue] for both fields. Doctrine does not allow generated identifier values for composite primary keys.
I cannot find an Auto Increment setting in the Field Setup for these views.
Workaround and the remaining problem
Manually changing the relevant .pmp field properties from
FldIsPrimaryKey="1" FldAutoIncrement="1"
to
FldIsPrimaryKey="1" FldAutoIncrement="0"
prevents PHPMaker from generating #[GeneratedValue] for those fields, while preserving the composite primary key.
However, this workaround does not persist.
I have just tested this again: PHPMaker identifies the corrected .pmp file as not matching the database and modifies the project definition. The FldAutoIncrement settings are restored, the invalid #[GeneratedValue] attributes are generated again, and the original Doctrine exception returns.
I have reproduced this behaviour with PHPMaker 2026.15. The issue is therefore still not fixed in this version.
Questions
-
Is this a known issue when generating Doctrine entities for views with composite primary keys?
-
Could PHPMaker avoid generating
#[GeneratedValue]for primary-key fields of views unless the database metadata actually indicates that the identifier is generated? -
Is there a supported way to configure composite primary keys for views without PHPMaker overwriting the necessary settings when it checks the project definition against the database?
A permanent solution would be appreciated. Manually correcting the .pmp file is not sufficient if PHPMaker subsequently resets the changes.