3

i am trying to set up a symfony2 project on a HHVM machine,

The HHVM is running on FastCGI as explained in the hhvm tutorial, thus running behind an apache2 server on Debian.

I have created everything but when i try to run my application i am getting the following error:

ContextErrorException: 16777217: Declaration of Doctrine\DBAL\Driver\PDOConnection::prepare() must be compatible with that of Doctrine\DBAL\Driver\Connection::prepare() in /LOCATION/shared/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php line 30

I am thinking this has something to do with PDO in HHVM but i tested it using the class_exists('PDO') and that says that PDO is enabled

Maxim
  • 3,836
  • 6
  • 42
  • 64

3 Answers3

6

This is an issue that was fixed via a pull request to the master branch of doctrine/dbal about 2 months ago. However, depending on the branch of Symfony 2 you are using, that doctrine/dbal fix may not be included.

https://github.com/doctrine/dbal/pull/373

If it is possible to use a version of Symfony 2 that includes this latest doctrine/dbal fix, I think you will see that issue go away.

Joel Marcey
  • 1,748
  • 14
  • 13
  • i am using the 2.4 branch – Maxim Feb 20 '14 at 09:17
  • So Symfony's 2.4 branch has a composer.json which gets the 2.4.x-dev 1770ffa version of doctrine/dbal. doctrine/dbal 2.4.x-dev does not have the fix referenced by the pull request above. So if you change the Symfony 2.4 composer.json to explicitly get the master branch of dbal/doctrine, that should hopefully help you. – Joel Marcey Feb 20 '14 at 18:11
  • Doing this resolves the issue, however, it seems to break the authentication system, though it is not clear why. After upgrading my dbal deps, I am no longer able to register or login, though this works fine under PHP 5.5 (my app only uses 5.4 code). – csvan Apr 03 '14 at 15:04
2

I've had the same issue and upgrading doctrine/orm and doctrine/dbal to latest versions (listed below) fixed my problems.

doctrine/orm : 2.5.@dev doctrine/dbal: 2.5.@dev

To safely upgrade, open your composer.json file, find and change the versions like so:

composer.json

"require": {
    // ... other package requirements
    "doctrine/orm": "~2.5.*@dev",
    "doctrine/dbal: "~2.5.*@dev", 
    // .. more packages

Then run composer update doctrine/* which will remove the old versions of doctrine and update all doctrine packages.

dnshio
  • 914
  • 1
  • 8
  • 21
  • It is great that you have mentioned `composer update doctrine/*` (especially the asterix in the end). I didn't know about this feature and was always having troubles when I had to update only certain dependencies... This helps a lot. – Dimitry K Dec 06 '14 at 19:51
  • 2
    However as of now there's stable versions of `doctrine/doctrine-bundle 1.3.*` there's stable `doctrine/dbal 2.5.*` and today's latest stable `doctrine/orm 2.4.6` as it's dependency constraint on `doctrine/dbal` specified `~2.4`. Which means that it accepts today's latest `2.5` as well. Which means that in typical symfony2 project we only need to specify `"doctrine/orm" : "~2.4.6"` and `"doctrine/doctrine-bundle" : "~1.3.0"`. And there's no need to explicitly set `doctrine/dbal` neither adding `@dev` to depend on unstable versions. :) HTH – Dimitry K Dec 06 '14 at 19:54
1

The declaration of

Doctrine\DBAL\Driver\PDOConnection::query() 

must be compatible with

PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs)

I had the same problem, but the solution was to just change the PHP version from version 8 to 7.3.

  • Login to your Cpanel with your credentials, search for MultiPHP Manager.
  • Select the domain or subdomain that you would like to change the PHP version of.
  • Select from the dropdown menu and chose the appropriate PHP version. (For me, 7.3 worked like a charm.)

Everything worked like it supposed to.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77