Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Class 'PDO' not found... #5786

Closed
victor-lund opened this issue Oct 14, 2016 · 9 comments
Closed

PHP Fatal error: Class 'PDO' not found... #5786

victor-lund opened this issue Oct 14, 2016 · 9 comments
Labels

Comments

@victor-lund
Copy link

My composer.json:

{
    "config": {
       "vendor-dir": "vendor"
    },
    "require": {
        "lcobucci/jwt": "^3.1",
        "doctrine/orm": "*",
        "jms/serializer": "*",
        "zircote/swagger-php": "^2.0"
    },
    "autoload": {
        "psr-4": {"Autoload\\": "src/"}
    }
}

Output of composer diagnose:

> docker exec af1f4436bcbf /bin/sh -c "cd /var/www/html/; php7 /usr/bin/composer diagnose"
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
require.doctrine/orm : unbound version constraints (*) should be avoided
require.jms/serializer : unbound version constraints (*) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK

When I run this command:

> docker exec af1f4436bcbf /bin/sh -c "cd /var/www/html/; vendor/bin/doctrine" 

I get the following output:

PHP Fatal error:  Class 'PDO' not found in /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php on line 172

And I expected this to happen:
The Doctrine module should work and return the CLI Interface...

@fbourigault
Copy link

doctrine\dbal does not depends on ext-pdo as an user can use a different extension. You must yourself depends on ext-pdo that seems not being available in the docker image you use.
Anyway this is not a composer\composer issue.

@victor-lund
Copy link
Author

If the issue indeed isn't related to Composer, I will close. However - the docker image should have pdo enabled and istalled. Looking at phpinfo() i get the following:

PDO

PDO support                 enabled
PDO drivers                 mysql, pgsql

pdo_mysql

PDO Driver for MySQL        enabled
Client API version          10.1.17-MariaDB
Directive                   Local Value                 Master Value
pdo_mysql.default_socket    /run/mysqld/mysqld.sock/    run/mysqld/mysqld.sock

and when listing composer's installed packages running:

docker exec 9f46d5a887e6 /bin/sh -c "cd /var/www/html/; php7 /usr/bin/composer show -p"

I get the following output:

...
ext-PDO             7.0.11   The PDO PHP extension
ext-pdo_mysql       7.0.11   The pdo_mysql PHP extension
ext-pdo_pgsql       7.0.11   The pdo_pgsql PHP extension
ext-pgsql           7.0.11   The pgsql PHP extension
ext-Phar            2.0.2    The Phar PHP extension
...

So as far as i can see, the docker image contains what it necessary.

@alcohol
Copy link
Member

alcohol commented Oct 14, 2016

Your Dockerfile is missing. We have no idea what your image contains.

@stof
Copy link
Contributor

stof commented Oct 14, 2016

you are not executing the same docker container to show the packages than when running doctrine. So it is possible that you have different extensions in both.

@alcohol
Copy link
Member

alcohol commented Oct 14, 2016

@stof Good catch. If multiple containers are involved, then this is most likely a pebkac error. We see those all too often ;-)

@victor-lund
Copy link
Author

@stof It is actually the same container, i rebuilt the whole system so the containers have different ID's in the two posts. Sorry for the confusion though..!

@alcohol The image I am using: https://github.com/ngineered/nginx-php-fpm/blob/php7/Dockerfile

I also checked the logs after the image was build and there were no errors to be found, so no clues there unfortunately

@alcohol
Copy link
Member

alcohol commented Oct 14, 2016

You are installing both php5 and php7. That is just asking for trouble.

@victor-lund
Copy link
Author

@alcohol Are you referring to line 39: "php5-soap " in the Dockerfile? Not sure why it needs to be there. Do you think it is causing troubles?

@victor-lund
Copy link
Author

@alcohol Very nice catch - your suspicions regarding php5 was indeed right. I tried to use the php5 image instead of the php7 one and all the problems disapared.

Big thanks to you and @stof - closing the issue and posting your findings at ngineered/nginx-php-fpm instead. Have a good weekend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants