PHPackages                             cooperl/laravel-db2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. cooperl/laravel-db2

ActiveLibrary[Database &amp; ORM](/categories/database)

cooperl/laravel-db2
===================

laravel-db2 is a simple DB2 service provider for Laravel. It provides DB2 Connection by extending the Illuminate Database component of the laravel framework.

9.0.2(3y ago)58120.3k↓88.9%67[27 issues](https://github.com/cooperl22/laravel-db2/issues)[2 PRs](https://github.com/cooperl22/laravel-db2/pulls)1MITPHPPHP ^8.0|^8.1|^8.2

Since Apr 22Pushed 2y ago11 watchersCompare

[ Source](https://github.com/cooperl22/laravel-db2)[ Packagist](https://packagist.org/packages/cooperl/laravel-db2)[ RSS](/packages/cooperl-laravel-db2/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (63)Used By (1)

laravel-db2
===========

[](#laravel-db2)

[![Latest Stable Version](https://camo.githubusercontent.com/ddfaf60f7c28723babec9ad03ee0c5ced4eba565838776403d599ee03e140ffd/68747470733a2f2f706f7365722e707567782e6f72672f636f6f7065726c2f6c61726176656c2d6462322f762f737461626c65)](https://packagist.org/packages/cooperl/laravel-db2)[![Total Downloads](https://camo.githubusercontent.com/317c4a5bf9e6e081e51a17bc43859ade7748f9b7046ac52c98611aa0169f64ca/68747470733a2f2f706f7365722e707567782e6f72672f636f6f7065726c2f6c61726176656c2d6462322f646f776e6c6f616473)](https://packagist.org/packages/cooperl/laravel-db2)[![Latest Unstable Version](https://camo.githubusercontent.com/58a5583cde6cb7ba2974638ebe3ccf6c915b027b8c0f236993c63e9ff31bf459/68747470733a2f2f706f7365722e707567782e6f72672f636f6f7065726c2f6c61726176656c2d6462322f762f756e737461626c65)](https://packagist.org/packages/cooperl/laravel-db2)[![License](https://camo.githubusercontent.com/2778c08056b18b12f40194b484120e59f2f86424f94c4f87e9645f0934a76301/68747470733a2f2f706f7365722e707567782e6f72672f636f6f7065726c2f6c61726176656c2d6462322f6c6963656e7365)](https://packagist.org/packages/cooperl/laravel-db2)

laravel-db2 is a simple DB2 service provider for Laravel. It provides DB2 Connection by extending the Illuminate Database component of the laravel framework.

---

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)

Installation
------------

[](#installation)

Add laravel-db2 to your composer.json file:

```
"require": {
    "cooperl/laravel-db2": "^8.0"
}

```

Use [composer](https://getcomposer.org) to install this package.

```
$ composer update

```

### Database Configuration

[](#database-configuration)

There are two ways to configure laravel-db2. You can choose the most convenient way for you. You can put your DB2 credentials into `config/database.php` (option 1) file or use package config file which you can generate through command line by artisan (option 2).

Please check appropriate specific DSN parameters for your connection. For instance here are the ODBC keywords for IBMi [https://www.ibm.com/support/knowledgecenter/fr/ssw\_ibm\_i\_74/rzaik/connectkeywords.htm](https://www.ibm.com/support/knowledgecenter/fr/ssw_ibm_i_74/rzaik/connectkeywords.htm)

If you encounter issues with char fields containing characters outside the invariant character set (for example: "ü") in PHP applications using the UTF8 locale the workaround to prevent the extra garbage data is to set the following connection string keyword: `DEBUG = 65536`

#### Option 1: Configure DB2 using `config/database.php` file

[](#option-1-configure-db2-using-configdatabasephp-file)

Simply add this code at the end of your `config/database.php` file:

```
    /*
    |--------------------------------------------------------------------------
    | DB2 Databases
    |--------------------------------------------------------------------------
    */

    'ibmi' => [
        'driver' => 'db2_ibmi_odbc',
        // or 'db2_ibmi_ibm' / 'db2_zos_odbc' / 'db2_expressc_odbc
        'driverName' => '{IBM i Access ODBC Driver}',
        // or '{iSeries Access ODBC Driver}' / '{IBM i Access ODBC Driver 64-bit}'
        'host' => 'server',
        'username' => '',
        'password' => '',
        'database' => 'WRKRDBDIRE entry',
        'prefix' => '',
        'schema' => 'default schema',
        'port' => 50000,
        'date_format' => 'Y-m-d H:i:s',
        // or 'Y-m-d H:i:s.u' / 'Y-m-d-H.i.s.u'...
        'odbc_keywords' => [
            'SIGNON' => 3,
            'SSL' => 0,
            'CommitMode' => 2,
            'ConnectionType' => 0,
            'DefaultLibraries' => '',
            'Naming' => 0,
            'UNICODESQL' => 0,
            'DateFormat' => 5,
            'DateSeperator' => 0,
            'Decimal' => 0,
            'TimeFormat' => 0,
            'TimeSeparator' => 0,
            'TimestampFormat' => 0,
            'ConvertDateTimeToChar' => 0,
            'BLOCKFETCH' => 1,
            'BlockSizeKB' => 32,
            'AllowDataCompression' => 1,
            'CONCURRENCY' => 0,
            'LAZYCLOSE' => 0,
            'MaxFieldLength' => 15360,
            'PREFETCH' => 0,
            'QUERYTIMEOUT' => 1,
            'DefaultPkgLibrary' => 'QGPL',
            'DefaultPackage' => 'A /DEFAULT(IBM),2,0,1,0',
            'ExtendedDynamic' => 0,
            'QAQQINILibrary' => '',
            'SQDIAGCODE' => '',
            'LANGUAGEID' => 'ENU',
            'SORTTABLE' => '',
            'SortSequence' => 0,
            'SORTWEIGHT' => 0,
            'AllowUnsupportedChar' => 0,
            'CCSID' => 819,
            'GRAPHIC' => 0,
            'ForceTranslation' => 0,
            'ALLOWPROCCALLS' => 0,
            'DB2SQLSTATES' => 0,
            'DEBUG' => 0,
            'TRUEAUTOCOMMIT' => 0,
            'CATALOGOPTIONS' => 3,
            'LibraryView' => 0,
            'ODBCRemarks' => 0,
            'SEARCHPATTERN' => 1,
            'TranslationDLL' => '',
            'TranslationOption' => 0,
            'MAXTRACESIZE' => 0,
            'MultipleTraceFiles' => 1,
            'TRACE' => 0,
            'TRACEFILENAME' => '',
            'ExtendedColInfo' => 0,
        ],
        'options' => [
            PDO::ATTR_CASE => PDO::CASE_LOWER,
            PDO::ATTR_PERSISTENT => false
        ]
        + (defined('PDO::I5_ATTR_DBC_SYS_NAMING') ? [PDO::I5_ATTI5_ATTR_DBC_SYS_NAMINGR_COMMIT => false] : [])
        + (defined('PDO::I5_ATTR_COMMIT') ? [PDO::I5_ATTR_COMMIT => PDO::I5_TXN_NO_COMMIT] : [])
        + (defined('PDO::I5_ATTR_JOB_SORT') ? [PDO::I5_ATTR_JOB_SORT => false] : [])
        + (defined('PDO::I5_ATTR_DBC_LIBL') ? [PDO::I5_ATTR_DBC_LIBL => ''] : [])
        + (defined('PDO::I5_ATTR_DBC_CURLIB') ? [PDO::I5_ATTR_DBC_CURLIB => ''] : [])
    ],
```

driver setting can be:

- 'db2\_ibmi\_odbc' for IBMi ODBC connection
- 'db2\_ibmi\_ibm' for IBMi PDO\_IBM connection
- 'db2\_zos\_odbc' for zOS ODBC connection
- 'db2\_expressc\_odbc for Express-C ODBC connection

Then if driver is 'db2\_\*\_odbc', database must be set to ODBC connection name. if driver is 'db2\_ibmi\_ibm', database must be set to IBMi database name (WRKRDBDIRE).

#### Option 2: Configure DB2 using package config file

[](#option-2-configure-db2-using-package-config-file)

Run on the command line from the root of your project:

```
$ php artisan vendor:publish

```

Set your laravel-db2 credentials in `config/db2.php`the same way as above

### Queue Configuration

[](#queue-configuration)

Simply set database connection driver value to `'db2_odbc'` in `config/queue.php` file:

Usage
-----

[](#usage)

Consult the [Laravel framework documentation](https://laravel.com/docs).

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance11

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 76.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~48 days

Recently: every ~80 days

Total

60

Last Release

1203d ago

Major Versions

7.0.x-dev → 8.0.02020-09-25

6.1.1 → 8.0.12021-12-10

8.1.1 → 9.0.12022-03-09

6.1.2 → 7.1.12022-03-09

7.1.1 → 9.0.02022-03-10

PHP version history (12 changes)1.0PHP &gt;=5.4.0

5.3PHP &gt;=5.6.4

5.5.0PHP &gt;=7.0.0

5.6.0PHP &gt;=7.1.3

6.0.0PHP ^7.2

7.0.0PHP ^7.2.5

8.0.0PHP ^7.3

8.1.0PHP ^7.3|^8.0

6.1.2PHP ^7.2|^8.0

7.1.1PHP ^7.2.5|^8.0

9.0.0PHP ^8.0

9.0.2PHP ^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c51ddf86c2ad1a98b84063fc095921af6a9f9ad4d0ffa4e09715ef69a7d74b5?d=identicon)[cooperl](/maintainers/cooperl)

---

Top Contributors

[![cooperl22](https://avatars.githubusercontent.com/u/12048268?v=4)](https://github.com/cooperl22 "cooperl22 (32 commits)")[![sarahkemp](https://avatars.githubusercontent.com/u/2836313?v=4)](https://github.com/sarahkemp "sarahkemp (3 commits)")[![boivinj](https://avatars.githubusercontent.com/u/90038153?v=4)](https://github.com/boivinj "boivinj (2 commits)")[![lucasmezencio](https://avatars.githubusercontent.com/u/472412?v=4)](https://github.com/lucasmezencio "lucasmezencio (2 commits)")[![chrisdicarlo](https://avatars.githubusercontent.com/u/3483368?v=4)](https://github.com/chrisdicarlo "chrisdicarlo (1 commits)")[![bironeaj](https://avatars.githubusercontent.com/u/16939160?v=4)](https://github.com/bironeaj "bironeaj (1 commits)")[![mfrancisc](https://avatars.githubusercontent.com/u/10716933?v=4)](https://github.com/mfrancisc "mfrancisc (1 commits)")

---

Tags

databasedriverlaravel-db2laravel-frameworkodbcphplaraveldatabasepdodb2odbc

### Embed Badge

![Health badge](/badges/cooperl-laravel-db2/health.svg)

```
[![Health](https://phpackages.com/badges/cooperl-laravel-db2/health.svg)](https://phpackages.com/packages/cooperl-laravel-db2)
```

###  Alternatives

[cooperl/laravel-ibmi

laravel-ibmi is a simple DB2 &amp; Toolkit for IBMi service provider for Laravel. It provides DB2 Connection by extending the Illuminate Database component of the laravel framework. Plus it also provides Toolkit for IBMi so that you can access IBMi resources with same credentials.

1013.9k](/packages/cooperl-laravel-ibmi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
