Skip to content

Update README.md #30

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

Merged
merged 1 commit into from
Feb 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 64 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Interface for PHP to DB2 for z/OS, DB2 for LUW, DB2 for i.

## Pre-requisites

The minimum PHP version supported by driver is PHP 7.3 and the latest version supported is PHP 8.1.
The minimum PHP version supported by driver is PHP 7.3 and the latest version supported is PHP 8.2.

## IBM i users

Expand Down Expand Up @@ -34,36 +34,48 @@ PHP, gcc, make, tar should be installed in your system.

You may not find gcc, make, tar in some of the docker containers (Example Amazon Linux2).
In such cases use below command to install gcc etc.

```shell
yum install make gcc
```
## How to install php ibm_db2 extension in Linux/Mac.
```
if IBM_DB_HOME and LD_LIBRARY_PATH environment variable not set then set them with installed CLIDRIVER.
(say CLIDRIVER installed at "/home/user/clidriver")

If `IBM_DB_HOME` and `LD_LIBRARY_PATH` environment variable not set then set them with installed CLIDRIVER.
(say CLIDRIVER installed at `/home/user/clidriver`)

```shell
export IBM_DB_HOME=/home/user/clidriver
export LD_LIBRARY_PATH=/home/user/clidriver/lib
export PATH=/home/user/clidriver/bin:$PATH
export LD_LIBRARY_PATH="${IBM_DB_HOME}/lib"
export PATH="${IBM_DB_HOME}/bin":$PATH
```

In case of Docker (Example Amazon Linux2), execute `db2level` command in your command prompt. If any error comes then install
`pam` from package manager:

In case of Docker(Example Amazon Linux2):
execute 'db2level' command in your command prompt, If any error comes then install 'pam' from package manager.
yum install pam
```shell
yum install pam
```

1) pecl install ibm_db2
1. Install this extension:

```shell
pecl install ibm_db2
```

2) Open the php.ini file in an editor of your choice. Edit the extension entry in the
php.ini file in the <local_php_directory>/php/lib directory to reference the PHP driver:
extension=ibm_db2.so
2. Open the `php.ini` file in an editor of your choice. Edit the extension entry in the
`php.ini` file in the `<local_php_directory>/php/lib` directory to reference the PHP driver:

```ini
extension=ibm_db2.so
```

3) Ensure that the PHP driver can access the libdb2.so CLI driver file by
setting the LD_LIBRARY_PATH variable for Linux and UNIX operating systems
other than the AIX® operating system. For AIX operating system, you must set LIBPATH variable.
3. Ensure that the PHP driver can access the `libdb2.so` CLI driver file by
setting the `LD_LIBRARY_PATH` variable for Linux and UNIX operating systems
other than the AIX® operating system. For AIX operating system, you must set `LIBPATH` variable.

4) Optional: If the PHP application that is connecting to an IBM database server is running ini
the HTTP server environment, add the LD_LIBRARY_PATH variable in the httpd.conf file.
4. Optional: If the PHP application that is connecting to an IBM database server is running ini
the HTTP server environment, add the `LD_LIBRARY_PATH` variable in the `httpd.conf` file.

```
## Prebuilt binaries for Windows

1. Add the `CLIDRIVER\bin` path to the `PATH` environment variable like so (for a batch file):
Expand All @@ -75,50 +87,55 @@ In case of Docker(Example Amazon Linux2):

3. Open the `php.ini` file in an editor of your choice. Edit the extension entry in the
`php.ini` file in the `<local_php_directory>\php\lib` directory to reference the driver:
````

```ini
extension=php_ibm_db2
````
```

## How to run sample program

### connect.php:-
Create a `connect.php` script with the following content:

```
```php
<?php

$database = 'dsn name';
$user = 'user';
$password = 'password';
$conn = db2_connect($database, $user, $password);

if ($conn) {
echo "Connection succeeded.";
echo 'Connection succeeded.';
db2_close($conn);
}
else {
echo "Connection failed: " . db2_conn_errormsg();
} else {
echo 'Connection failed: ' . db2_conn_errormsg();
}
?>
```

To run the sample:- php connect.php
Run the sample program:

```shell
php connect.php
```

## How to build from source code in Linux or Mac
```
Use the commands included in the source code:
download Source code from https://pecl.php.net/package/ibm_db2
a) Extract the source archive
b) Run the following commands from the extracted directory:
$ phpize --clean
$ phpize
$ ./configure --with-IBM_DB2=/home/user/clidriver
$ make
$ make install
```

1. Download Source code from https://pecl.php.net/package/ibm_db2
2. Extract the source archive
3. Run the following commands from the extracted directory:

```shell
phpize --clean
phpize
./configure --with-IBM_DB2=/home/user/clidriver
make
make install
```
## How to build from source code in Windows
```
Below blog mentiones how to build php ibm_db2 from source in windows.
https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/Install_PHP_ibm_db2_Driver?lang=en

```
[This blog](https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/Install_PHP_ibm_db2_Driver?lang=en)
mentions how to build php ibm_db2 from source in Windows.

## Test suite

Expand All @@ -144,9 +161,10 @@ the amount of systems in the wild without a properly set QCCSID, but you
should do this anyways. To check and set QCCSID, run `WRKSYSVAL` from a 5250.

## Contributing:
```
See CONTRIBUTING.md

The developer sign-off should include the reference to the DCO in defect remarks(example below):
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
The developer sign-off should include the reference to the DCO in defect remarks, like in this example:

```
DCO 1.1 Signed-off-by: Random J Developer <random@developer.org>
```