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)

Most upvoted comments

@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 enable oci8.so specifically for the phpdbg 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 if oci8 is not loaded, there’s a problem with the client architecture, the required environment variables (ORACLE_HOME and/or LD_LIBRARY_PATH), or oci8 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.

Unfortunately, I can’t replicate the issue and not really sure how to fix this. If anyone finds a solution, please do not hesitate to submit a PR. Thanks!

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 uses php7.2

Still working for me. There might be something odd on your table which may cause the issue?

Route::get('/', function () {
    dump(DB::select('select * from users where rownum=1'));
    dd(DB::table('users')->first());
});
array:1 [▼
  0 => {#1369 ▼
    +"id": "1"
    +"first_name": "CMS"
    +"last_name": "Administrator"
    +"email": "admin@example.com"
    +"email_verified_at": null
    +"is_activated": "1"
    +"is_blocked": "0"
    +"password": "$2y$10$F8GAwF/tAl6HWDvxxvqDDOkGstYvV8jmahvPbI3bRc.54U821qfeK"
    +"avatar": null
    +"parameters": null
    +"is_admin": "1"
    +"remember_token": "hkx4oIZ4MP"
    +"verification_token": null
    +"deleted_at": null
    +"created_by": "0"
    +"updated_by": "0"
    +"created_at": "2019-05-09 02:33:36"
    +"updated_at": "2019-05-09 02:33:36"
  }
]
{#1375 ▼
  +"id": "1"
  +"first_name": "CMS"
  +"last_name": "Administrator"
  +"email": "admin@example.com"
  +"email_verified_at": null
  +"is_activated": "1"
  +"is_blocked": "0"
  +"password": "$2y$10$F8GAwF/tAl6HWDvxxvqDDOkGstYvV8jmahvPbI3bRc.54U821qfeK"
  +"avatar": null
  +"parameters": null
  +"is_admin": "1"
  +"remember_token": "hkx4oIZ4MP"
  +"verification_token": null
  +"deleted_at": null
  +"created_by": "0"
  +"updated_by": "0"
  +"created_at": "2019-05-09 02:33:36"
  +"updated_at": "2019-05-09 02:33:36"
}