Firebird 4.0 (or 5.0) and PHP 8.3 (or 8.2) PDO driver

407 views
Skip to first unread message

Roberto Carlos

unread,
Dec 2, 2023, 12:26:41 AM12/2/23
to firebi...@googlegroups.com
Firebird 4.0 (or 5.0) and PHP 8.3 (or 8.2) PDO driver
 
1. Is it possible to use Firebird 4.0 (or even Firebird 5.0 RC) and PHP 8.3 (or PHP 8.2) PDO driver?
 
* PHP 7.4 was released on 28 Nov 2019 and ended its security support on 28 Nov 2022 (EOL).
 
Official Firebird documentation says that only PHP 7.4 ibase driver works:
[out-of-date page] https://firebirdsql.org/en/devel-php-driver/
[out-of-date page] https://firebirdsql.org/en/php-driver/
https://github.com/FirebirdSQL/php-firebird/releases
 
 
 
2. If so, where to start or how to start?
 
 
Articles
 
Lester Caine has pulled together a series of links to articles about <using Firebird with the various PHP stacks> over many years. (Scroll down to the list of search results.)
[broken link]  https://lsces.uk/search/index.php?content_type_guid=bitpage&highlight=firebird
 
An <on-line test> using various Firebird commands with the older driver (use password masterkey to connect)
[broken link] https://smallbrook.uk/ibtest.php
 
 
 
Observation:
- I know how to set up Debian + Apache + PHP 8.3 to work with MySQL, MariaDB and PostgreSQL.
- I also know how to install Firebird 4.0 and 5.0 RC on Debian Linux.
 
3. How to set up Debian, Ubuntu or Mint Linux to allow using Firebird 4.0 (or Firebird 5.0 RC) and PHP 8.3 (or PHP 8.2) PDO driver?
 
GitHub - FirebirdSQL/php-firebird: Firebird PHP driver
https://github.com/FirebirdSQL/php-firebird/
 

Thanks for any information.
 
 

Roberto Carlos

unread,
Dec 2, 2023, 12:40:37 AM12/2/23
to firebi...@googlegroups.com
Firebird 4.0 (or 5.0) and PHP 8.3 (or 8.2) PDO driver
 
------------------------------------------------
These 3 messages were previously also sent to firebird...@googlegroups.com.
------------------------------------------------
 
 
It's a new project.
 
My idea is exactly to take advantage of the new features from FB4 now and from FB5 as soon as it's released.
 
How did you managed to build the Firebird PDO driver on Debian Linux?
 
I am follwing the steps on  https://github.com/FirebirdSQL/php-firebird/  without success.
 
 
# vim php.ini
----------
extension=interbase
extension=pdo_firebird
----------
 
# php -m | grep firebird
 
 
Thanks.
------------------------------------------------
 
 
I have imagined that the PHP driver for Firebird maintained by Martin Koeditz included ibase and PDO libraries at the same time, but it seems that I was wrong: this solution seems to cover only the original ibase driver that was discontinued in PHP a few years ago because of recurring errors that were never fixed and due to the lack of updating to support newer versions of Firebird.
 
The original ibase driver that was discontinued in PHP was very old and contained several limitations even with Firebird 2.5.
 
The original PDO driver still present in PHP is also very old and continues to contain limitations even with Firebird 2.5, which is about to be discontinued. This original PDO driver also has more and more bigger limitations for newer versions of Firebird (3.0, 4.0 and 5.0).
 
 
1. I would like to know if the PHP driver for Firebird maintained by Martin Koeditz is up to date with the new features provided by Firebird 4.0 and 5.0, which is about to be released.
 
 
2. I would like to know if it is possible and HOW TO DO it for the PHP ibase driver for Firebird maintained by Martin Koeditz to be adapted or converted or recompiled to become PHP PDO driver as well.
 
 
If possible, my goal is to start a new project with Debian 12 Linux, PHP 8.3 (using PDO) (or maybe ORM, which also depends on PDO), Firebird 4.0 (migrating to 5.0 as soon as possible).
 
 
Almost eight years ago, since the original ibase driver became overly limiting in using the new features of Firebird 3.0.0 (April 19, 2016), I had created a RESTful API using Free Pascal Lazarus as CGI so that I could continue to evolve along with Firebird. That solution was great. It was supposed to be temporary, but it has become permanent until now.
 
 
Thanks for any help.
 
 

Emil Totev

unread,
Dec 2, 2023, 2:48:33 AM12/2/23
to Firebird-PHP
Hi

Yes, it is possible to use firebird 4.0 (and most probably 5.0) with php 8.2 and probably 8.3, but - as you have noted yourself - with certain limitations. I have a couple of small projects that use the old interbase (ibase*) driver with php up to 8.2 and they generally work.

Pre-compiled binaries for php-interbase are available at https://github.com/FirebirdSQL/php-firebird (for linux) and https://github.com/mlazdans/php-firebird (for Windows.) There are none for php 8.3 yet, but hopefully they will be added soon. I have no experience with compiling the driver myself, I don't know if it is complicated or not. 
Once you have the needed binary, you should put it in the php extensions directory with the proper name, and add the corresponding line in you php.ini.

Support for BOOLEAN fields has been added and works, new datatypes from 4.0 like decfloat, int128 and timestamps with time zones are still not supported. I guess they can be added, but I don't know how high is that on Martin's priority list. That's why if you are using 4.0 or above, you definitely need to add DataTypeCompatibility = 3.0 to your firebird.conf (or databases.conf). Even if you are not using them directly, the server may return new datatypes in some situations.

Long identifiers are not supported by the PHP drivers and it is not likely they will be any time soon. The problem is that this feature is available only via the new OO client interface and the drivers need to be completely rewritten to use it instead of the old ISC API. I don't know of any plans to do that, neither for php-interbase nor for pdo_firebird.

I don't know what other new features you are planning to use. Generally, everything that is server-only, like the replication, should be no problem.

My advice is that you re-consider the database part of your project. Using Firebird makes sense if you are going to make full use of its strengths - like if you plan to put most of the business logic in the database. From what I've seen in most php frameworks and ORM implementations, the database is used only as data store, and they are mostly centered around MySQL/MariaDB and Postgres (and SQLite - although it is not a server, it might be a good option too). Support for Firebird is either non-existent or third-party.

Now that I looked more carefully, I see that your question was actually about the PDO driver. It is still supported in PHP, so it should be available from your package manager one way or another. I don't have much experience with it yet, as far as I know Boolean support was added there too, but not other new datatypes, so the recommendation for DataCompatibility probably stands.

Hope that helps a little.

Best regards
Emil

martin.koeditz

unread,
Dec 4, 2023, 8:33:23 AM12/4/23
to Firebird-PHP
Hi,

as Email noted:

1. The driver is not up to date with the newest features. INT 128 and TimeZones are missing. If anyone can help to implement it, that would be great.

2. Technically it should be doable to have one driver for PDO and legacy. But that would be hard work. There are several things to mention to avoid breaking some working codes.

I'm currently checking if it's possible to switch from ISC to OO API. IMHO the problem here is the poor description of the PHP extension interface.

Everything that runs on the Firebird server itself can be "fired" by the driver. Here, the client driver doesn't matter.

Regards
Martin
Reply all
Reply to author
Forward
0 new messages