• Stars
    star
    829
  • Rank 55,018 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Oracle DB driver for Laravel via OCI8

Oracle DB driver for Laravel 4|5|6|7|8|9|10 via OCI8

Build Status Total Downloads Latest Stable Version License

Laravel-OCI8

Laravel-OCI8 is an Oracle Database Driver package for Laravel. Laravel-OCI8 is an extension of Illuminate/Database that uses OCI8 extension to communicate with Oracle. Thanks to @taylorotwell.

Documentations

Laravel Version Compatibility

Laravel Package
5.1.x 5.1.x
5.2.x 5.2.x
5.3.x 5.3.x
5.4.x 5.4.x
5.5.x 5.5.x
5.6.x 5.6.x
5.7.x 5.7.x
5.8.x 5.8.x
6.x.x 6.x.x
7.x.x 7.x.x
8.x.x 8.x.x
9.x.x 9.x.x
10.x.x 10.x.x

Quick Installation

composer require yajra/laravel-oci8:^10

Service Provider (Optional on Laravel 5.5+)

Once Composer has installed or updated your packages you need to register Laravel-OCI8. Open up config/app.php and find the providers key and add:

Yajra\Oci8\Oci8ServiceProvider::class,

Configuration (OPTIONAL)

Finally you can optionally publish a configuration file by running the following Artisan command. If config file is not publish, the package will automatically use what is declared on your .env file database configuration.

php artisan vendor:publish --tag=oracle

This will copy the configuration file to config/oracle.php.

Note: For Laravel Lumen configuration, make sure you have a config/database.php file on your project and append the configuration below:

'oracle' => [
    'driver'         => 'oracle',
    'tns'            => env('DB_TNS', ''),
    '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', ''),
    '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'        => [],
],

Then, you can set connection data in your .env files:

DB_CONNECTION=oracle
DB_HOST=oracle.host
DB_PORT=1521
DB_SERVICE_NAME=orcl
DB_DATABASE=xe
DB_USERNAME=hr
DB_PASSWORD=hr

If you want to connect to a cluster containing multiple hosts, you can either set tns manually or set host as a comma-separated array and configure other fields as you wish:

DB_CONNECTION=oracle
DB_HOST=oracle1.host, oracle2.host
DB_PORT=1521
DB_SERVICE_NAME=orcl
DB_LOAD_BALANCE=no
DB_DATABASE=xe
DB_USERNAME=hr
DB_PASSWORD=hr

If you need to connect with the service name instead of tns, you can use the configuration below:

'oracle' => [
    'driver' => 'oracle',
    'host' => 'oracle.host',
    'port' => '1521',
    'database' => 'xe',
    'service_name' => 'sid_alias',
    'username' => 'hr',
    'password' => 'hr',
    'charset' => '',
    'prefix' => '',
]

In some cases you may wish to set the connection parameters dynamically in your app. For instance, you may access more than one database, or your users may already have their own accounts on the Oracle database:

'oracle' => [
    'driver' => 'oracle',
    'host' => 'oracle.host',
    'port' => '1521',
    'service_name' => 'sid_alias',
    'prefix' => 'schemaowner',
    'dynamic' => [App\Models\Oracle\Config::class, 'dynamicConfig'],
]

The callback function in your app must be static and accept a reference to the $config[] array (which will already be populated with values set in the config file):

namespace App\Models\Oracle;

class Config {

    public static function dynamicConfig(&$config) {

        if (Illuminate\Support\Facades\Auth::check()) {
            $config['username'] = App\Oracle\Config::getOraUser();
            $config['password'] = App\Oracle\Config::getOraPass();
        }

    }
}

Then run your laravel installation...

Oracle Max Name Length

By default, DB object name are limited to 30 characters. To increase the limit, you can set the ORA_MAX_NAME_LEN=128 in your .env file.

Note: this config requires Oracle 12c02 or higher.

[Laravel 5.2++] Oracle User Provider

When using oracle, we may encounter a problem on authentication because oracle queries are case sensitive by default. By using this oracle user provider, we will now be able to avoid user issues when logging in and doing a forgot password failure because of case sensitive search.

To use, just update auth.php config and set the driver to oracle

'providers' => [
    'users' => [
        'driver' => 'oracle',
        'model' => App\User::class,
    ],
]

Credits

License

The MIT License (MIT). Please see License File for more information.

More Repositories

1

laravel-datatables

jQuery DataTables API for Laravel
PHP
4,740
star
2

laravel-datatables-html

Laravel DataTables HTML Builder Plugin
PHP
272
star
3

laravel-datatables-buttons

Laravel DataTables Buttons Plugin
PHP
252
star
4

laravel-admin-template

Laravel 4.2 Bootstrap Admin Starter Template [with Oracle DB Support]
JavaScript
152
star
5

laravel-auditable

Basic Auditable package for Eloquent Model.
PHP
149
star
6

laravel-datatables-demo

Laravel Datatables Package Demo App
HTML
146
star
7

laravel-datatables-editor

Laravel DataTables Editor Integration.
PHP
115
star
8

laravel-acl

Laravel ACL is a simple role, permission ACL for Laravel Framework.
PHP
107
star
9

datatables

A package that installs the complete Laravel DataTables core & plugins.
PHP
96
star
10

laravel-datatables-fractal

Laravel DataTables Fractal Plugin.
PHP
95
star
11

laravel-datatables-docs

Laravel DaTatables package documentation
92
star
12

pdo-via-oci8

PHP PDO_OCI functions via OCI8 extension
PHP
88
star
13

laravel-disqus

A simple Disqus platform integration with Laravel.
PHP
84
star
14

laravel-address

Philippines Regions, Provinces, Cities and Barangays Address Lookup API for Laravel.
PHP
33
star
15

homestead-oracle

Laravel local development environment with Oracle XE 11g
Shell
31
star
16

laravel-datatables-export

Laravel DataTables Export plugin that uses queue, spout and livewire for bulk data export.
PHP
29
star
17

dt54

Laravel 5.4 DataTables Demo Application
PHP
24
star
18

laravel-datatables-vite

Laravel DataTables with Vite
JavaScript
20
star
19

cms-core

YajraCMS Core Module
PHP
19
star
20

zillow

A simple Laravel Wrapper for the Zillow API services.
PHP
15
star
21

laravel-datatables-scout

Laravel DataTables plugin to support Laravel Scout.
PHP
12
star
22

laravel-datatables-assets

A personal collection of DataTables server-side and client-side scripts.
JavaScript
10
star
23

laravel-datatables-ui

Laravel DataTables UI Preset
PHP
10
star
24

laravel-sql-loader

Oracle SQL*Loader for Laravel
PHP
9
star
25

yajrabox.com

Source code of yajrabox.com website.
PHP
7
star
26

laravel-4.1-starter-kit

Laravel 4.1 Starter Kit with Oracle DB Support
PHP
7
star
27

cms-themes

YajraCMS Themes Module
PHP
7
star
28

laravel-breadcrumbs

A simple Laravel style way to create breadcrumbs
PHP
6
star
29

laravel-datatables-tailwind-experiment

Blade
6
star
30

laravel-auditable-docs

Laravel Auditable Package Docs
5
star
31

laravel-oci8-docs

Laravel OCI8 package documentation
5
star
32

laravel-datatables-starter

Laravel 5.5 and DataTables starter kit.
PHP
5
star
33

laravel-acl-docs

Laravel ACL Docs
4
star
34

laravel-datatables-inertia

Laravel InertiaJS with DataTables
4
star
35

clean-blog

A clean blog theme for YajraCMS.
HTML
3
star
36

analytics-module

YajraCMS Google Analytics Module
HTML
2
star
37

yajra.github.io

HTML
1
star
38

laravel-datatables-compatibility

Laravel DataTables v8 plugin for v7 backward compatibility.
PHP
1
star
39

dt-searchpanes-demo

Laravel DataTables Server-Side searchPane demo
PHP
1
star
40

datatables.net-tailwindcss

jQuery DataTables using TailwindCSS with Editor support.
1
star