Skip to content

Support

Laravel-OCI8 integrates seamlessly with Laravel's database system. This guide shows how to establish Oracle database connections in your application.

Setting Up the Connection

Configure your Oracle database connection in config/database.php:

'connections' => [
'oracle' => [
'driver' => 'oracle',
'host' => env('DB_HOST', ''),
'port' => env('DB_PORT', '1521'),
'database' => env('DB_DATABASE', ''),
'service_name' => env('DB_SERVICE_NAME', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'AL32UTF8'),
'prefix' => env('DB_PREFIX', ''),
],
],

Accessing the Oracle Connection

Using the Query Builder

use Illuminate\Support\Facades\DB;
 
// Query the Oracle connection
$users = DB::connection('oracle')
->table('users')
->where('active', true)
->get();

Setting a Default Connection

In config/database.php:

'default' => env('DB_CONNECTION', 'oracle'),

Working with Models

Using the Config

In your Eloquent models, specify the connection:

<?php
 
namespace App\Models;
 
use Illuminate\Database\Eloquent\Model;
 
class User extends Model
{
protected $connection = 'oracle';
protected $table = 'users';
}

Using a Base Model

For projects that use Oracle exclusively, set the default connection in a base model:

<?php
 
namespace App\Models;
 
use Illuminate\Database\Eloquent\Model;
 
abstract class BaseModel extends Model
{
protected $connection = 'oracle';
}

Learning More

For comprehensive documentation on Laravel's database features, see the official Laravel documentation:

Getting Help

Community Support

Professional Support

For commercial support and consulting, contact the maintainer directly.

Troubleshooting

Common Issues

Connection Refused

// Verify your Oracle credentials
// Check that the Oracle listener is running
// Ensure the host and port are correct

Invalid Identifier

// This usually means the table or column doesn't exist
// Check your table names match exactly (Oracle is case-sensitive)
// Remember: Oracle auto-uppercases unquoted identifiers

Character Set Mismatch

// Ensure your database charset matches your connection charset
// AL32UTF8 is recommended for Unicode support

For more troubleshooting guidance, see the GitHub Issues.

See Also