Installing php PDO OCI driver using pecl

I am trying to install the PDO driver for OCI.

When searching on Google for pdo_oci, I find the following URL:

https://pecl.php.net/package/PDO_OCI

It displays this message at the top of the page:

This package is no longer supported and has been superseded. The package has moved to the channel http://www.php.net/pdo_oci , package ext / pdo_oci.

What does this post mean, how to add this channel using pecl?

I tried to add this feed using pear channel-discover php.net/pdo_oci

but it doesn't work. I also cannot find the channel.xml file for php.net/pdo_oci to try pear channel-add channel.xml

.

+3


source to share


2 answers


EDIT

If you already have php installed (for example from the repository) you can only compile PDO_OCI from PHP source (you need to install instantclient)

Inside the pdo_oci folder, run the following commands:

$ phpize  
$ ./configure --with-pdo-oci=instantclient,/usr,12.1  
$ make && make install  
$ echo "extension=pdo_oci.so" > /etc/php.d/pdo_oci.ini  
$ service httpd restart

      

This method will create pdo_oci.so in PHP extensions folder only, no need to recompile all PHP. You can do it with PHP repositories versions, and you can do it with any extension inside the ext folder in the PHP source.


First, sorry for my bad english.

I had the same question, but I could already solve it.

As the post says, this PECL extension has been deprecated. You need to compile PHP from source with PDO_OCI, which is included in PHP Source.

I made this path on CentOS 6.6 , with MySQL, Apache and InstantClient installed:

Install dependencies like

curl-devel
freetype-devel
libc-client
libc-client-devel
libjpeg-devel
libmcrypt-devel
libpng-devel
libtool-ltdl-devel
libxml2-devel
libXpm-devel
libc-client
libc-client-devel
libmcrypt-devel
libpng-devel
db4-devel

...And other prompted dependencies in the ./configure 
(always install the *-devel package too)

      

Download PHP Source Code

$ wget http://ar2.php.net/get/php-5.6.10.tar.gz/from/this/mirror  

      

Unzip the downloaded file and go to the folder

$ tar -xzf php-5.6.10.tar.gz  
$ cd php-5.6.10  

      



Run the configure command with the options you want (my example is below)

./configure \   
--prefix=/usr \  
--sysconfdir=/etc \  
--localstatedir=/var \  
--datadir=/usr/share/php \  
--mandir=/usr/share/man \  
--with-config-file-path=/etc \  
--with-config-file-scan-dir=/etc/php.d \  
--with-zlib \  
--enable-bcmath \  
--with-bz2 \  
--enable-calendar \  
--with-gdbm \  
--with-gmp \  
--enable-ftp \  
--with-gettext \  
--enable-mbstring \  
--with-readline \  
--with-apxs2 \  
--with-pdo-oci=instantclient,/usr,12.1 \  
--enable-dba=shared \  
--with-pdo-mysql --with-mysql-sock=/var/mysql/mysql.sock \  
--with-pdo-pgsql \ 
--with-mcrypt \  
--with-mhash \  
--with-curl \  
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-vpx-dir=/usr \
--with-freetype-dir=/usr \
--with-t1lib=/usr \
--with-libxml-dir=/usr \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \  
--enable-soap \
--with-xmlrpc \
--with-xsl \
--with-tidy=/usr \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvmsg \
--enable-shmop

      

If you see any error when running this command, you are probably missing some dependency (possibly a dependency I did not mention).

After running configure command without error

$ make && make install  

      

PHP is already installed at this point. For certification, run the following command:

$ php -v  

      

But before we finish we need to make some changes ...

Copy php.ini to correct directory

### If you're on a development server    
$ cp php.ini-development /etc/php.ini

### If you're on a production server
$ cp php.ini-production /etc/php.ini

      

Open the Apache config file for editing

$ vi /etc/httpd/conf/httpd.conf

      

Add the following lines to have Apache interpret PHP (ignore if they are already there)

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps   

      

Restart Apache

$ service httpd restart

      

+5


source


After installing Oracle drivers, you can use this that class here and then you just need to change your PDO connection to something like

$pdo = new PDO("oci:dbname=mydatabase;charset=utf8", "user", "password");

      

to



$pdo = new PDOOCI\PDO("mydatabase", "user", "password");

      

The rest should work exactly the same as if you were using a PDO object.

+1


source







All Articles