Laravel & Lumen with Informix DB

I was looking to try and work with Lumen to create a API frontend for few services we have, and the problem I had was to make Laravel/Lumen to work with Informix DB. I found a small package called laravel-ifx which seems to answer my need, but it was not updated to support Laravel 5.7, trying to install it will result with a conflict. Seems like few others had the same problem and forked the repo, and updated the composer.json file to remove/change the version requirement from 5.2.* to 5.*.

Also, Laravel from version 5.6 support auto loading service providers, so I also added this lines to my composer file,

Laravel

And then in my project I add a remote repo to point my version of the package

and then require the package

and next will publish the config file for informix

Now update the .env file with the require info to connect to the DB

Lumen

laravel-ifx can work with Lumen but it require a bit more manual work. Lumen is missing a helper function which exist in Laravel, so we will have to define it manually.

create a new file in your project called “app/Support/helpers.php” and this lines to it.

create the config folder on the project root dir and copy the informix.php file from laravel-ifx/config folder to it.

Next will update the bootstrap/app.php file to allow the use of the new provider,

enable $app->withFacades(); and $app->withEloquent();  and add the line  $app->configure('informix');  after them, and then register the provider with $app->register(Poyii\Informix\InformixDBServiceProvider::class); 

Resources

  • https://laracasts.com/discuss/channels/lumen/fixing-apparent-laravel-package-incompatibility-with-lumen
  • https://getcomposer.org/doc/03-cli.md#modifying-repositories

 

 

Related Post

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *