microsoft / msphpsql

Microsoft Drivers for PHP for SQL Server
MIT License
1.8k stars 374 forks source link

The packages sqlsrv and pdo_sqlsrv version 5.10.0 do not work for PHP 8.0 on Debian 11 #1377

Closed drupal-daffie closed 2 years ago

drupal-daffie commented 2 years ago

Please check the FAQ (frequently-asked questions) first. If you have other questions or something to report, please address the following (skipping questions might delay our responses):

PHP version 8.0

PHP SQLSRV or PDO_SQLSRV version 5.10.0

Microsoft ODBC Driver version 18

SQL Server version Not important

Client operating system Debian 11

Table schema Not important

Problem description
I have changed the default PHP version from 8.1 to 8.0. When I run php -v it returns to me that I am running version 8.0. I then install the packages sqlsrv and pdo_sqlsrv, like:

sudo pecl channel-update pecl.php.net
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.0/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.0/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -v 8.0 sqlsrv pdo_sqlsrv

When I than run php -v I get the following warning:

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /usr/lib/php/20200930/pdo_sqlsrv.so (/usr/lib/php/20200930/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20200930/pdo_sqlsrv.so.so (/usr/lib/php/20200930/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /usr/lib/php/20200930/pdo_sqlsrv.so (/usr/lib/php/20200930/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20200930/pdo_sqlsrv.so.so (/usr/lib/php/20200930/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /usr/lib/php/20200930/sqlsrv.so (/usr/lib/php/20200930/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20200930/sqlsrv.so.so (/usr/lib/php/20200930/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /usr/lib/php/20200930/sqlsrv.so (/usr/lib/php/20200930/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20200930/sqlsrv.so.so (/usr/lib/php/20200930/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 8.0.13 (cli) (built: Nov 22 2021 09:47:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies

Installing it for PHP 8.1 works great. Thank you for that.

Expected behavior and actual behavior Make it compile for PHP 8.0 and PHP 7.4

Repro code or steps to reproduce See Problem description and I am using PHP from https://deb.sury.org/ with multiple versions of PHP.

rfay commented 2 years ago

Do they work on php7.4?

drupal-daffie commented 2 years ago

It fails with PHP 7.4 with the following result:

daffie@ddev-93mssql-web:/var/www/html/web$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /usr/lib/php/20190902/pdo_sqlsrv.so (/usr/lib/php/20190902/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_sqlsrv.so.so (/usr/lib/php/20190902/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /usr/lib/php/20190902/pdo_sqlsrv.so (/usr/lib/php/20190902/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_sqlsrv.so.so (/usr/lib/php/20190902/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /usr/lib/php/20190902/sqlsrv.so (/usr/lib/php/20190902/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/sqlsrv.so.so (/usr/lib/php/20190902/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /usr/lib/php/20190902/sqlsrv.so (/usr/lib/php/20190902/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/sqlsrv.so.so (/usr/lib/php/20190902/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.26 (cli) (built: Nov 22 2021 09:49:28) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies
rfay commented 2 years ago

Did you follow the instructions in https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15#step-3-install-the-php-drivers-for-microsoft-sql-server-ubuntu-with-php-fpm for 7.4 and 8.0?

rfay commented 2 years ago

I confirm your experience with PHP7.4 using the instructions in https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15#step-3-install-the-php-drivers-for-microsoft-sql-server-ubuntu-with-php-fpm

drupal-daffie commented 2 years ago

I followed the instructions and I got the fail.

absci commented 2 years ago

I can confirm this issue. A work around is after change version to 8.0 do pecl uninstall sqlsrv pdo_sqlsrv and then pecl install sqlsrv pdo_sqlsrv. We'll look into the possibilities of having pecl compile for different PHP versions.

drupal-daffie commented 2 years ago

@absci: Thank you!

absci commented 2 years ago

I did some research and I think it's not possible to let Pecl compile for all php versions during one install. But I found a solution here. I have both 8.0 and 8.1 installed on my machine.

sudo pecl -d php_suffix=8.1 install sqlsrv
sudo pecl uninstall -r sqlsrv
sudo pecl -d php_suffix=8.0 install sqlsrv
sudo pecl uninstall -r sqlsrv

After that both php versions can use sqlsrv extension.