Level 1
did you find the solution ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello.
I've a docker compose with an oracle xe db image:
hostname: localhost
port: 49161
sid: xe
username: system
password: oracle
So, I the .env file I set:
DB_CONNECTION=oracle
DB_HOST=localhost
DB_PORT=49161
DB_DATABASE=portalCiudadano
DB_USERNAME=system
DB_PASSWORD=oracle
and in database.php
'oracle' => [
'driver' => 'oracle',
'host' => env('ORACLE_HOST', ''),
'port' => env('ORACLE_PORT', '49161'),
'database' => env('ORACLE_DATABASE', ''),
'service_name' => env('ORACLE_SERVICE_NAME', ''),
'username' => env('ORACLE_USERNAME', ''),
'password' => env('ORACLE_PASSWORD', ''),
'charset' => 'utf8',
],
and this is the console output when I do a php artisan migrate:
InvalidArgumentException
Unsupported driver [oracle].
at vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:274
270▕ 'mysql' => new MySqlConnection($connection, $database, $prefix, $config),
271▕ 'pgsql' => new PostgresConnection($connection, $database, $prefix, $config),
272▕ 'sqlite' => new SQLiteConnection($connection, $database, $prefix, $config),
273▕ 'sqlsrv' => new SqlServerConnection($connection, $database, $prefix, $config), ➜ 274▕ default => throw new InvalidArgumentException("Unsupported driver [{$driver}]."),
275▕ };
276▕ }
277▕ }
278▕
So, I use yajra/laravel, using this commands:
composer require yajra/laravel-oci8:^9
and then:
php artisan vendor:publish --tag=oracle
Adding this line in database.php
'oracle' => [
'driver' => 'oracle',
'tns' => env('DB_TNS', ''),
'host' => env('DB_HOST', ''),
'port' => env('DB_PORT', '49161'),
'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', ''),
'prefix_schema' => env('DB_SCHEMA_PREFIX', ''),
'edition' => env('DB_EDITION', 'ora$base'),
'server_version' => env('DB_SERVER_VERSION', '11g'),
'load_balance' => env('DB_LOAD_BALANCE', 'yes'),
'dynamic' => [],
],
But the console output when I run php artisan migrate is:
Error
Undefined constant "Yajra\Pdo\OCI_DEFAULT"
Could you please help me?
Please or to participate in this conversation.