Formapro\Pvm\Doctrine\DoctrineDAL::__construct() must be an instance of Doctrine\Common\Persistence\ObjectManager, instance of Doctrine\ORM\EntityManager given #6521

Closed
opened 2026-01-22 15:34:28 +01:00 by admin · 4 comments
Owner

Originally created by @whittlem on GitHub (Aug 14, 2020).

I'm trying to get Formapro PVM working with Doctrine.

The error message I am getting is:

Fatal error: Uncaught TypeError: Argument 1 passed to Formapro\Pvm\Doctrine\DoctrineDAL::__construct() must be an instance of Doctrine\Common\Persistence\ObjectManager, instance of Doctrine\ORM\EntityManager given, called in <removed>/scripts/myapp.php on line 77 and defined in <removed>/vendor/formapro/pvm/src/Doctrine/DoctrineDAL.php:28
Stack trace:
#0 <removed>/scripts/myapp.php(77): Formapro\Pvm\Doctrine\DoctrineDAL->__construct(Object(Doctrine\ORM\EntityManager), 'MYAPP\\Doctrine\\Or...', 'MYAPP\\Doctrine\\Or...')
#1 {main}
  thrown in <removed>/vendor/formapro/pvm/src/Doctrine/DoctrineDAL.php on line 28

According to the documentation example I'm supposed to be passing EntityManager as the first argument:
$doctrineDal = new DoctrineDAL($entityManager, OrmProcess::class, OrmToken::class);

The error message above seems to suggest this should be ObjectManager now and I'm not sure how to upgrade this. It does not look like ObjectManager has a "create" method.

The current relevant code looks like this:

use Doctrine\ORM\EntityManager;

$credentials = array (
    'test' => array (
        'username' => <removed>,
        'pw' => <removed>,
        'connstr' => <removed>,
        'host'  => <removed>
    )
);

$conn = [
    'url' => 'oci8:' . $credentials[$dbName]['username'] .':'. $credentials[$dbName]['pw'] . '@' . $credentials[$dbName]['host'] ."/" . $credentials[$dbName]['connstr'],
    'user' => $credentials[$dbName]['username'],
    'password' => <removed>,
    "connectstring" => $credentials[$dbName]['host'] ."/" . $credentials[$dbName]['connstr']
];

$entityManager = EntityManager::create($conn, $config);

In Doctrine how do I create the ObjectManager instead of EntityManager to pass to:
$doctrineDal = new DoctrineDAL($objectManager, OrmProcess::class, OrmToken::class);

The versions I'm using in composer are:

"formapro/pvm": "^0.4.7"
"symfony/yaml": "3.*"
"doctrine/orm": "^2.6.2",
Originally created by @whittlem on GitHub (Aug 14, 2020). I'm trying to get Formapro PVM working with Doctrine. The error message I am getting is: ``` Fatal error: Uncaught TypeError: Argument 1 passed to Formapro\Pvm\Doctrine\DoctrineDAL::__construct() must be an instance of Doctrine\Common\Persistence\ObjectManager, instance of Doctrine\ORM\EntityManager given, called in <removed>/scripts/myapp.php on line 77 and defined in <removed>/vendor/formapro/pvm/src/Doctrine/DoctrineDAL.php:28 Stack trace: #0 <removed>/scripts/myapp.php(77): Formapro\Pvm\Doctrine\DoctrineDAL->__construct(Object(Doctrine\ORM\EntityManager), 'MYAPP\\Doctrine\\Or...', 'MYAPP\\Doctrine\\Or...') #1 {main} thrown in <removed>/vendor/formapro/pvm/src/Doctrine/DoctrineDAL.php on line 28 ``` According to the documentation example I'm supposed to be passing EntityManager as the first argument: `$doctrineDal = new DoctrineDAL($entityManager, OrmProcess::class, OrmToken::class);` The error message above seems to suggest this should be ObjectManager now and I'm not sure how to upgrade this. It does not look like ObjectManager has a "create" method. The current relevant code looks like this: ``` use Doctrine\ORM\EntityManager; $credentials = array ( 'test' => array ( 'username' => <removed>, 'pw' => <removed>, 'connstr' => <removed>, 'host' => <removed> ) ); $conn = [ 'url' => 'oci8:' . $credentials[$dbName]['username'] .':'. $credentials[$dbName]['pw'] . '@' . $credentials[$dbName]['host'] ."/" . $credentials[$dbName]['connstr'], 'user' => $credentials[$dbName]['username'], 'password' => <removed>, "connectstring" => $credentials[$dbName]['host'] ."/" . $credentials[$dbName]['connstr'] ]; $entityManager = EntityManager::create($conn, $config); ``` In Doctrine how do I create the ObjectManager instead of EntityManager to pass to: `$doctrineDal = new DoctrineDAL($objectManager, OrmProcess::class, OrmToken::class);` The versions I'm using in composer are: ``` "formapro/pvm": "^0.4.7" "symfony/yaml": "3.*" "doctrine/orm": "^2.6.2", ```
admin added the Question label 2026-01-22 15:34:28 +01:00
admin closed this issue 2026-01-22 15:34:28 +01:00
Author
Owner

@SenseException commented on GitHub (Aug 14, 2020):

Which version of ORM and Persistence are installed in your project? ^2.6.2 can be a wide range of versions (see composer docs).

You might take a look at the library where Formapro\Pvm\Doctrine\DoctrineDAL is used. Doctrine Persistence was moved from Common into its own repository and your project's dependencies probably don't fit together.

@SenseException commented on GitHub (Aug 14, 2020): Which version of ORM and Persistence are installed in your project? `^2.6.2` can be a wide range of versions (see [composer docs](https://getcomposer.org/doc/articles/versions.md#caret-version-range-)). You might take a look at the library where `Formapro\Pvm\Doctrine\DoctrineDAL` is used. Doctrine Persistence was moved from Common into its own repository and your project's dependencies probably don't fit together.
Author
Owner

@whittlem commented on GitHub (Aug 17, 2020):

Thanks for the reply.

name     : doctrine/orm
descrip. : Object-Relational-Mapper for PHP
keywords : database, orm
versions : * v2.7.3
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : https://www.doctrine-project.org/projects/orm.html
source   : [git] https://github.com/doctrine/orm.git d95e03ba660d50d785a9925f41927fef0ee553cf
dist     : [zip] https://api.github.com/repos/doctrine/orm/zipball/d95e03ba660d50d785a9925f41927fef0ee553cf d95e03ba660d50d785a9925f41927fef0ee553cf
path     : /var/SP/httpd/ccp-dev/ccp-dev.vodafone.com/vendor/doctrine/orm
names    : doctrine/orm
name     : doctrine/persistence
descrip. : The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
keywords : mapper, object, odm, orm, persistence
versions : * 2.0.0
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : https://doctrine-project.org/projects/persistence.html
source   : [git] https://github.com/doctrine/persistence.git 1dee036f22cd5dc0bc12132f1d1c38415907be55
dist     : [zip] https://api.github.com/repos/doctrine/persistence/zipball/1dee036f22cd5dc0bc12132f1d1c38415907be55 1dee036f22cd5dc0bc12132f1d1c38415907be55
path     : /var/SP/httpd/ccp-dev/ccp-dev.vodafone.com/vendor/doctrine/persistence
names    : doctrine/persistence

The issue I have is that DoctrineDAL is expecting ObjectManager as the first argument and all the documentation says it should be EntityManager. I'm not sure how to create that ObjectManager instance to pass it. I've sort of run out of options now and I can't seem to find a solution online.

@whittlem commented on GitHub (Aug 17, 2020): Thanks for the reply. ``` name : doctrine/orm descrip. : Object-Relational-Mapper for PHP keywords : database, orm versions : * v2.7.3 type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : https://www.doctrine-project.org/projects/orm.html source : [git] https://github.com/doctrine/orm.git d95e03ba660d50d785a9925f41927fef0ee553cf dist : [zip] https://api.github.com/repos/doctrine/orm/zipball/d95e03ba660d50d785a9925f41927fef0ee553cf d95e03ba660d50d785a9925f41927fef0ee553cf path : /var/SP/httpd/ccp-dev/ccp-dev.vodafone.com/vendor/doctrine/orm names : doctrine/orm ``` ``` name : doctrine/persistence descrip. : The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share. keywords : mapper, object, odm, orm, persistence versions : * 2.0.0 type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : https://doctrine-project.org/projects/persistence.html source : [git] https://github.com/doctrine/persistence.git 1dee036f22cd5dc0bc12132f1d1c38415907be55 dist : [zip] https://api.github.com/repos/doctrine/persistence/zipball/1dee036f22cd5dc0bc12132f1d1c38415907be55 1dee036f22cd5dc0bc12132f1d1c38415907be55 path : /var/SP/httpd/ccp-dev/ccp-dev.vodafone.com/vendor/doctrine/persistence names : doctrine/persistence ``` The issue I have is that DoctrineDAL is expecting ObjectManager as the first argument and all the documentation says it should be EntityManager. I'm not sure how to create that ObjectManager instance to pass it. I've sort of run out of options now and I can't seem to find a solution online.
Author
Owner

@whittlem commented on GitHub (Aug 17, 2020):

Composer won't actually let me downgrade to doctrine/orm:^2.6 as per https://pvm-demo.forma-pro.com/demo/store-to-mysql

According to this https://www.doctrine-project.org/projects/orm.html, 2.7.3 is stable and anything lower is not maintained. So I guess I am committed to making this work. I just need help to find out how to create the DoctrineDAL using an ObjectManager rather than an EntityManager.

@whittlem commented on GitHub (Aug 17, 2020): Composer won't actually let me downgrade to doctrine/orm:^2.6 as per https://pvm-demo.forma-pro.com/demo/store-to-mysql According to this https://www.doctrine-project.org/projects/orm.html, 2.7.3 is stable and anything lower is not maintained. So I guess I am committed to making this work. I just need help to find out how to create the DoctrineDAL using an ObjectManager rather than an EntityManager.
Author
Owner

@mxmp210 commented on GitHub (Sep 14, 2020):

Composer won't actually let me downgrade to doctrine/orm:^2.6 as per https://pvm-demo.forma-pro.com/demo/store-to-mysql

According to this https://www.doctrine-project.org/projects/orm.html, 2.7.3 is stable and anything lower is not maintained. So I guess I am committed to making this work. I just need help to find out how to create the DoctrineDAL using an ObjectManager rather than an EntityManager.

To anyone getting stuck with this,
Just use "doctrine/common":"^2.13" till package is upgraded along with whole eco-system and gets full compatibility.
It installed orm version 2.7.3 which is stable release at the moment of writing. took me a quite while to figure out why packages aren't in sync even in LTS / stable channel.

For Search Optimization I'm quoting FOSUserBundle exception as well :

Argument 3 passed to FOS\UserBundle\Doctrine\UserManager::__construct() must be an instance of Doctrine\Common\Persistence\ObjectManager, instance of Doctrine\ORM\EntityManager given, called in

@mxmp210 commented on GitHub (Sep 14, 2020): > > > Composer won't actually let me downgrade to doctrine/orm:^2.6 as per https://pvm-demo.forma-pro.com/demo/store-to-mysql > > According to this https://www.doctrine-project.org/projects/orm.html, 2.7.3 is stable and anything lower is not maintained. So I guess I am committed to making this work. I just need help to find out how to create the DoctrineDAL using an ObjectManager rather than an EntityManager. To anyone getting stuck with this, Just use "doctrine/common":"^2.13" till package is upgraded along with whole eco-system and gets full compatibility. It installed orm version 2.7.3 which is stable release at the moment of writing. took me a quite while to figure out why packages aren't in sync even in LTS / stable channel. For Search Optimization I'm quoting FOSUserBundle exception as well : > Argument 3 passed to FOS\UserBundle\Doctrine\UserManager::__construct() must be an instance of Doctrine\Common\Persistence\ObjectManager, instance of Doctrine\ORM\EntityManager given, called in
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6521