MAMP: PHP -m shows oci8 enabled, but not in phpinfo - php

My objective is to connect to Oracle database through OCI8 which is available through:
pecl install oci8-2.0.11
To achieve that, I've been following various tutorials on the Net to make it work.
I followed the following tutorials:
http://www.baldwhiteguy.co.nz/technical/index_files/mac-osx-oracle-instantclient.html
http://www.enavigo.com/2012/01/04/enabling-oracle-oci8-php-extension-on-os-x-snow-leopard/
http://tomytree22.blogspot.my/2014/09/oci-driver-installation-on-mac.html
These tutorials are enough to run SQL Plus. I am also able to successfully run pecl install oci-8.20.11 and get this output:
You should add "extension=oci8.so" to php.ini
In the 3rd tutorial I listed above, I followed all except under instantclient library has some hardcoded paths we need to take care of:
When I run php -m, I can see the oci8 is there, but I don't see it inside my phpinfo. What did I do wrong?
When I tried to connect to the Oracle database anyway, I am stuck with this:
Fatal error: Call to undefined function oci_connect()
I hope someone here can help me. I'm using El Capitan.

So I fixed it. Here's how I get to the solution.
I looked into my php log (make sure you enabled your PHP to log all errors! Just go to your error_log path to look for your error) and I found this:
[06-May-2016 09:48:12 Europe/Berlin] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so' - dlopen(/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so, 9): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
and
[09-May-2016 04:53:51 Europe/Berlin] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so' - dlopen(/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so, 9): Library not loaded: /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib
So oci8.so is not loaded because there are two libraries that are not loaded.
Here's how I fixed it:
And that means, the one that I skipped which is instantclient library has some hardcoded paths we need to take care of: is the one I needed. So I run these commands (copy pasted from the tutorial):
sudo mkdir -p /ade/b/3071542110/oracle/rdbms/lib/
sudo ln -sf /Applications/MAMP/bin/php/php5.5.10/lib/php/instantclient_11_2/libclntsh.dylib.11.1 /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
sudo mkdir -p /ade/dosulliv_ldapmac/oracle/ldap/lib/
sudo ln -sf /Applications/MAMP/bin/php/php5.5.10/lib/php/instantclient_11_2/libnnz11.dylib /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib
and then I restarted my MAMP. And now I got what I want, which is OCI8. Now the info is available on my PHPInfo.
Hope this will help the rest of guys who are embarking the same path of setting up OCI to connect to Oracle on MAMP.

Related

PHP Warning: PHP Startup: Unable to load dynamic library 'cassandra.so' (tried: /usr/lib/php/20170718/cassandra

I'm setting up square api, integrated it in client side and now working on server side but for that i need to manage dependencies with composer, while installing composer I got above error.
I was installing composer, when i run composer install, composer was installed but I got the PHP warning in addition i.e
PHP Warning: PHP Startup: Unable to load dynamic library
'cassandra.so' (tried: /usr/lib/php/20170718/cassandra.so
(/usr/lib/php/20170718/cassandra.so: cannot open shared object file:
No such file or directory), /usr/lib/php/20170718/cassandra.so.so
(/usr/lib/php/20170718/cassandra.so.so: cannot open shared object
file: No such file or directory)) in Unknown on line 0
I googled and tried all the solutions that have already been done, but none worked to mine. I have tried:
To find out cassandra at php.ini in /etc/php/7.2/cli but i did't find it.
To install Cassandra by using command sudo apt-get install php-cassandra in /usr/lib/php/20170718, but it still shows the same error.
Update and upgrade the Ubuntu, to make sure that there are no internal errors, if there was any?
I expect to install cassandra and load it dynamically.
The DataStax PHP driver extension is a wrapper around the C/C++ driver and requires installation of all of its dependencies:
C/C++ driver
libuv 1.x
OpenSSL v1.0.x or v1.1.x (depends on how your PHP is built)
The GNU Multiple Precision Arithmetic Library
Since you are using the PHP driver with PHP v7.2 you will need to build the extension as their are no pre-built binaries for this version of PHP:
git clone https://github.com/datastax/php-driver.git
cd php-driver/ext
phpize
cd ..
mkdir build
cd build
../ext/configure
make
sudo make install
Note: The development packages of all of dependencies will be required in order to properly build the extension.
Once the driver is installed you will need to edit your php.ini file to enable the extension which can be located by executing php -r "echo php_ini_loaded_file();":
; DataStax PHP Driver for Apache Cassandra
extension=cassandra.so
To ensure the the driver is being properly loaded via CLI you can execute the following:
php -m | grep cassandra
or
php -i | grep -A 10 "^cassandra$"
php -m will print out all the extension/modules that PHP was able to load whereas php -i will display more verbose information about your PHP installation configuration.

How to install php5-ldap extension while the server is offline on linux ubuntu

i am trying to install php5-ldap extension on my server which is ubuntu 16 and this server has no access to the internet, how do i go about?
Note: i have tried .deb files still i have not managed to solve the problem,
but when i used .deb files this error was coming out
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/ldap.so' - /usr/lib/php/20131226/ldap.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 '/usr/lib/php/20131226/ldap.so' - /usr/lib/php/20131226/ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0
Please someone help me to figure this out.
thank you in advance.
You can simple install on ubuntu desktop and copy this binary extensions to /usr/lib/php/20131226/ldap.so but this bad way. Better way download source and copy to server
$ cd /path/to/source
$ phpize
$ ./configure
$ make
$ make test
$ make install
but I can't find this extension, I think you need compile php with support ldap --with-ldap

Issue getting mac to use brew php version

I had php installed and now I am trying to switch over to valet-plus to I can switch between php versions easy but I am running into some issues.
I have php71 and php 56 install but it seems like my computer keeps trying to use php from /usr/bin/local which is not where brew installs them.
When I do a php -v i get a warning "PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so, 9): image not found in Unknown on line 0"
It is correct that file is not there. I installed mcrypt from brew with brew install php71-mcrypt. If I look at the php.ini file where brew installed it that will show that file in the different path.
This is my .bash_profile and I source it and no errors show up but still old php location is there.
# Prefer US English and use UTF-8
export LC_ALL="en_US.UTF-8"
export LANG="en_US"
export PATH="/usr/local/mysql/bin:$PATH"
#export PATH="/usr/local/php5/bin:$PATH"
export PATH="/usr/local/Cellar/php71/7.1.5_17/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
I looked at about 30 different topics similar but none of those helped me out. I have unlinked and relinked php, reinstalled from source. I just need some direction on what is causing my apache to use the php location it is using and not allowing brew to switch it over.
Thanks

Error In PHP5 ..Unable to load dynamic library

root#ip-10-131-9-200:/etc/php5/apache2# php -a
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/curl.so' - /usr/lib/php5/20090626+lfs/curl.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 '/usr/lib/php5/20090626+lfs/mcrypt.so' - /usr/lib/php5/20090626+lfs/mcrypt.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 '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.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 '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.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 '/usr/lib/php5/20090626+lfs/pdo.so' - /usr/lib/php5/20090626+lfs/pdo.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 '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Interactive shell
Even though several other answers suggest it, installing more unnecessary software is generally not the best solution. Instead, you should fix the underlying problem. The reason these messages appear is because you are trying to load those extensions, but they are not installed. So the easy solution is simply to tell PHP to stop trying to load them:
First, find out which files are trying to load the above extensions:
$ grep -Hrv ";" /etc/php5 | grep -E "extension(\s+)?="
Example output for Ubuntu:
/etc/php5/mods-available/gd.ini:extension=gd.so
/etc/php5/mods-available/pdo_sqlite.ini:extension=pdo_sqlite.so
/etc/php5/mods-available/pdo.ini:extension=pdo.so
/etc/php5/mods-available/pdo_mysql.ini:extension=pdo_mysql.so
/etc/php5/mods-available/mysqli.ini:extension=mysqli.so
/etc/php5/mods-available/mysql.ini:extension=mysql.so
/etc/php5/mods-available/curl.ini:extension=curl.so
/etc/php5/mods-available/sqlite3.ini:extension=sqlite3.so
/etc/php5/conf.d/mcrypt.ini:extension=mcrypt.so
/etc/php5/conf.d/imagick.ini:extension=imagick.so
/etc/php5/apache2/php.ini:extension=http.so
Now just find the files that are loading the extensions that are causing the errors and comment out those lines with a ;. For some reason this happened to me with the default install of Ubuntu, so hopefully this helps someone else.
sudo apt-get install php5-mcrypt
sudo apt-get install php5-mysql
...etc resolved it for me :)
hope it helps
Look /etc/php5/cli/conf.d/ and delete corresponding *.ini files. This error happens when you remove some php packages not so cleanly.
Seems like you upgraded PHP to newer version and old .ini files are still pointing to old location.
The solution: find out where are modules located now
ls -l /usr/lib/php5
There should be a directory similar to old 20090626. In my case it is now 20131226
The .ini files giving you an error are located at /etc/php5/cli/conf.d/
Just edit those .ini files which module gives you an error. For example, in case the error is for mcrypt module:
sudo vi /etc/php5/cli/conf.d/20-mcrypt.ini
Change the line:
extension=/usr/lib/php5/20090626/mcrypt.so
to reflect the new path for .so file. In my case the correct path should be:
extension=/usr/lib/php5/20131226/mcrypt.so
That's it! The error is gone. Ofc you'd have to do it with each module giving you an error.
If you put the ; symbol, this action inactive the extension.
I had the same problem and did the following:
Uninstall php with purge parameter:
sudo apt-get --purge remove php5-common
And install again:
sudo apt-get install php5 php5-mysql
My problem was solved by the following command
sudo apt-get install php5-mcrypt
I have
PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli)
Ubuntu Desktop 12.04
Mysql 5.5
I found this solution by blog.tordeu.com, and it's
sudo aptitude purge php5-suhosin
I'm not sure, but it seems that the suhosin is no longer needed, it worked for my, my PHP version:
PHP 5.4.34-1+deb.sury.org~lucid+1 (cli) (built: Oct 17 2014 15:26:51)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
If you are using 5.6 php,
sudo apt-get install php5.6-curl
Somehow the gmp.so file seems to have been deleted from my system. This is what fixed it for me:
sudo apt-get install --reinstall php5-gmp
Well for Ubuntu 14.04 I was getting that error just for mcrypt:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/mcrypt.ini' - /usr/lib/php5/20121212/mcrypt.ini: cannot open shared object file: No such file or directory in Unknown on line 0
If you have a closer look at the error, php is looking for mcrypt.ini and not for mcrypt.so at that location. I just copy mcrypt.so to mcrypt.ini and that's it, the warning is gone and the extension now is properly installed. It might look a bit dirty but it worked!
I had enabled the extension_dir in php.ini by uncommenting,
extension_dir = "ext"
extension=phpchartdir550.dll
and copying phpchartdir550 dll to the extension_dir (/usr/lib/php5/20121212), resulted in the same error.
PHP Warning: PHP Startup: Unable to load dynamic library 'ext/phpchartdir550.dll' - ext/phpchartdir550.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'ext/pdo.so' - ext/pdo.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 'ext/gd.so' - ext/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
As #Mike pointed out, it is not necessary to install all the stuff when they are not actually required in the application.
The easier way is to provide the full path to the extensions to be loaded after copying the libraries to the correct location.
Copy phpchartdir550.dll to /usr/lib/php5/20121212, which is the extension_dir in my Ubuntu 14.04 (this can be seen using phpinfo())
and then provide full path to the library in php.ini,
; extension=/path/to/extension/msql.so
extension=/usr/lib/php5/20121212/phpchartdir550.dll
restart apache: sudo service apache2 restart
even though other .so's are present in the same directory, only the required ones can be selectively loaded.
I had a similar problem, which led me here:
$ phpunit --version
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/profiler.so' - /usr/lib/php5/20131226/profiler.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.
Unlike the above, installing the software did not resolve my problem because I already had it.
$ sudo apt-get install php5-uprofiler
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-uprofiler is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 52 not upgraded.
I found my solution via : Debian Bug report logs
$ sudo vim /etc/php5/mods-available/uprofiler.ini
I edited the ini file, changing extension=profiler.so to extension=uprofiler.so .... the result, happily:
$ phpunit --version
PHPUnit 5.7.17 by Sebastian Bergmann and contributors.
i.e. no more warning.
(For Ubuntu users)
I had the same problem, but none of the answers above solved that. Here is how I solved the problem.
Open your php.ini file (mine was in /etc/php/7.3/cli/php.ini).
You may have something like this:
extension=pdo_mysql
Or maybe:
extension=/here/is/the/path/to/your/file/pdo_mysql.so
Add the following line before extension=pdo_mysql
extension=pdo
So, you will have:
extension=pdo
extension=pdo_mysql
It seems that the problem is (at least in my case) that we need to load pdo extension first to load the pdo_mysql extension.
Hope that helps!

PDOException “could not find driver” in php

I have installed Lampp on my linux system, and I am learning symfony2, while trying to create the schema with symfony2 command
php app/console doctrine:schema:create
I am getting the following error message:-
PDOException “could not find driver”
I also uncomment this line extension=php_pdo_mysql.dll in php.ini file
I tried to look and google my issue but couldn't resolve my problem. when i run php -m command i am getting the following result:-
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.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 '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.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 '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
openssl
pcntl
pcre
PDO
----
----
Is there a way i can remove this issue ?
In Ubuntu, write in the console
sudo apt-get install php5-gd php5-mysql
and it will work
Hope you are running your project in localhost. In your project folder app/config a file named parameters.ini , Make sure that your Mysql database connection cofiguration is correct. If you are using mysql See database_driver=pdo_mysql is its driver.
Below is an example.
database_driver = pdo_mysql
database_host = localhost
database_port =
database_name = databasename
database_user = msqlusername
database_password = mysqlpassword//if not make blank
mailer_transport = smtp
mailer_host = localhost
mailer_user =
mailer_password =
locale = en
secret = ThisTokenIsNotSoSecretChangeIt
Hope it helps you.
You need to have a module called pdo_mysql.
Look for the following in phpinfo() output,
pdo_mysql => PDO Driver for MySQL, client library version => 5.1.44
to install pdo_mysql you need to do this:
pecl install pdo
pecl install pdo_mysql
and then add the following to your php.ini file:
extension=pdo.so
extension=pdo_mysql.so
brew install php70-pdo-pgsql
in case you installed php7 on mac with brew and, change php version according to what you have installed.
if you are using XAMPP then in php.ini file line no 897(depends on version),
;extension=php_pdo_pgsql.dll
uncomment it , then it appears like below
extension=php_pdo_pgsql.dll
in php.ini file line no 897, then restart XAMPP.
There are two PHP versions installed in my server PHP 5.6 and PHP 7
When I run the command php app/console doctrine:schema:update I have the error : [PDOException] could not find driver
I resolve this error by specifying the PHP version:
php5.6 app/console doctrine:schema:update
Looks like your install is missing the .so files it needs to implement the mysql connection. If you're using a package management system to install PHP then make sure you've installed all the necessary submodules (in this case I think you'll need mysql-dev, and the various PHP PDO modules), though such dependencies should have been resolved for you by the package manager.
If you didn't go through a package manager, then you'll have to compile the required .so files from source.
I had the same problem and for me, it was having multiple PHP versions.
So specifying the full address of the PHP solved the problem.
Adding to Jaspreet Chahal's answer.
When installing PDO as a shared module, the php.ini file needs to be updated so that the PDO extension will be loaded automatically when PHP runs. You will also need to enable any database specific drivers there too; make sure that they are listed after the pdo.so line, as PDO must be initialized before the database-specific extensions can be loaded. If you built PDO and the database-specific extensions statically, you can skip this step(Source).
What I mean is, it should look something like this -
extension=pdo.so should be placed before the extensions of the different database drivers.
Maybe you forget to install doctrine/dbal
composer update
composer require doctrine/dbal
if it didn't work go to your php.ini (according to current version)
and remove ";"
;extension=pdo_mysql.so

Categories