laravel-oci8: Use of undefined constant OCI_CRED_EXT - assumed 'OCI_CRED_EXT' (this will throw an Error in a future version of PHP)
Summary of problem or feature request
I’m having error when trying to select table. Anyone can help?
Code snippet of problem
Route::get('test-oracle-connection', function () {
$sspd = \Illuminate\Support\Facades\DB::connection('oracle')->table('sspd')->first();
dd($sspd);
});
Errors:
Use of undefined constant OCI_CRED_EXT - assumed 'OCI_CRED_EXT' (this will throw an Error in a future version of PHP)
System details
- Operating System:
macOS Mojave Version 10.14.4 (18E226)
- PHP Version:
7.3
- Laravel Version:
5.8.*
- Laravel-OCI8 Version:
5.8.*
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 33 (9 by maintainers)
@shafiqruslan There’s nothing to “fix”. The OCI8 extension is not registered with PHP correctly, so you need to troubleshoot the reason for that.
I suggest reading my earlier post carefully. Check your
phpinfo()
output, and if the OCI8 extension is not listed, check the potential causes that I noted.Generally, this error seems to occur whenever the
oci8
PHP extension is not being loaded for whatever reason. Many of the other descriptions here, such as table reference quote syntax in runtime code, are probably red-herrings.For example, I encountered this error when debugging with
phpdbg
, which maintains a completely separate INI configuration from the regular PHP CLI executable. I had forgotten to create a symlink to enableoci8.so
specifically for thephpdbg
environment and received this error only when running tests.The bottom line: if you receive this error, check your
phpinfo()
output in whichever environment you are executing PHP (CLI, PHP-FPM, phpdbg, etc.) and ifoci8
is not loaded, there’s a problem with the client architecture, the required environment variables (ORACLE_HOME
and/orLD_LIBRARY_PATH
), oroci8
simply hasn’t been enabled in the effective PHP configuration file(s).@JPdiedhiou you need to use quotes on the table name like so
DB::table('table_name')
@yajra can this issue be closed since it was identified that the issue lies in the system configuration? Maybe a change in documentation to be a bit more verbose about the instantclient will solve future issues. Will try to compile some resources and help with this.
Yajra… simply put a 32-bit instant client in the path rather than a 64 bit and you will see this error.
I recently hit upon this issue and was able to resolve it. I came across the problem while updating PHP. The only resolution I’ve found thus far is to ensure that you are on 64 bit everything (Apache, PHP, AND Oracle Instant Client). Also, be sure to point your Apache (64-bit!) to the correct PHP (64-bit) in httpd.conf. Make sure the 64 bit Instant Client is on your path! Once all the pieces were in the right place… voila.
That undefined constant’s value is HUGELY negative (> 32-bit).
Hope this helps!
@yajra thank you, my problem has been solved. yesterday an error occurred because I used
php7.3
on the ubuntu setting but php apache2 still usesphp7.2
Still working for me. There might be something odd on your table which may cause the issue?