Connecting to Oracle: CodeIgniter vs Laravel

I was looking for a PHP framework for the project I'm currently working on. One of the basic requirements is an easy way to interact with our database. Initially, this should be Oracle, but there is the possibility of moving to another database in the future. Therefore, I want to be able to write code that is agnostic of the database as much as possible.

I initially leaned toward CodeIgniter, mainly because of Oracle support (it includes drivers written to use Oracle's native OCI8 drivers).

Laravel is another alternative that I have reviewed. This is a popular option, even with some previous CodeIgniter users (e.g. see this answer ). However, its support for Oracle seems very limited; as far as I can tell, Laravel makes extensive use of PDOs, but PDOs for Oracle are experimental and not recommended .

Is there an easy way to connect to Oracle using Laravel in agnostic database mode?

+7
oracle php codeigniter laravel
source share
2 answers

I'm not sure if this solves all the problems, but this packagist library should make Oracle work with Laravel.

Please note that OCI8 may still be a problem : /

+3
source share

After examining the link provided by fideloper , it appears that some useful coders (developers) have continued to develop a PDO user space driver for Oracle that takes advantage of the built-in PHP OCI8 driver functions.

According to this website, this can be installed in Laravel using the composer:

Add yajra/laravel-oci8 as a requirement for composer.json :

 { "require": { "yajra/laravel-oci8": "*" } } 

And then run:

 composer update 

After Composer has installed or updated your packages, you need to register a service provider. Open app / config / app.php and find the provider key and add:

 yajra\Oci8\Oci8ServiceProvider 

Finally, you need to configure the correct database configuration using the pdo-via-oci8 driver. Set up your connection as usual:

 'connection-name' => array( 'host' => 'something', 'port' => 'something', 'username' => 'something', 'password' => 'something', 'charset' => 'something', 'prefix' => 'something', ) 

Then Laravel can access Oracle in agnostic database mode using Eloquent etc. I gave this basic testing, it seems to work well.

+11
source share

All Articles