PHPackages                             beryildiz/db2-driver - 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. beryildiz/db2-driver

ActiveLibrary

beryildiz/db2-driver
====================

DB2 for IBM iSeries drop-in Laravel driver

v1.0.0(today)01↑2900%MITPHPPHP ^8.2

Since Aug 5Pushed todayCompare

[ Source](https://github.com/beryildiz/db2-driver)[ Packagist](https://packagist.org/packages/beryildiz/db2-driver)[ Docs](https://github.com/beryildiz/db2-driver)[ RSS](/packages/beryildiz-db2-driver/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (11)Versions (2)Used By (0)

![](https://camo.githubusercontent.com/507bfa8fa3851bce934817306497fdc118dcddd1987390ec2d4af66912f56b1c/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f6462322d6472697665722e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d62657279696c64697a2532466462322d647269766572267061747465726e3d62616e6b4e6f7465267374796c653d7374796c655f31266465736372697074696f6e3d4442322b666f722b49424d2b695365726965732b636f6e6e65637469766974792b666f722b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d736572766572267769647468733d6175746f)

[![Tests](https://github.com/beryildiz/db2-driver/actions/workflows/tests.yml/badge.svg)](https://github.com/beryildiz/db2-driver/actions/workflows/tests.yml)[![Static Analysis](https://github.com/beryildiz/db2-driver/actions/workflows/static.yml/badge.svg)](https://github.com/beryildiz/db2-driver/actions/workflows/static.yml)[![Latest Version](https://camo.githubusercontent.com/74ba06d94b9f5ecf2f82646d4e34abc2a2094ca83878538deb8409733c6ff5b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62657279696c64697a2f6462322d6472697665722e737667)](https://packagist.org/packages/beryildiz/db2-driver)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE.md)

DB2 for IBM iSeries Laravel Driver
==================================

[](#db2-for-ibm-iseries-laravel-driver)

This package lets you use Laravel's query builder and Eloquent with DB2 for IBM iSeries by extending the Illuminate Database component of the Laravel framework. It targets **Laravel 12 exclusively** and is actively maintained.

### Lineage

[](#lineage)

This driver has three generations behind it — each fork picked up where the previous one had stalled:

1. [cooperl22/laravel-db2](https://github.com/cooperl22/laravel-db2) — the original driver.
2. [BWICompanies/db2-driver](https://github.com/BWICompanies/db2-driver) — forked from (1), renamed the namespace and continued development.
3. **beryildiz/db2-driver** (this repository) — forked from (2). Rewritten for Laravel 12 compatibility (constructor and method signatures across the schema layer changed in Laravel 11/12 and made the previous version fatal on class load), with an expanded test suite, static analysis via Larastan, and the limitations below turned into explicit, documented exceptions instead of silently wrong SQL. See [CHANGELOG.md](CHANGELOG.md) for the full list of breaking changes and fixes.

Requirements
------------

[](#requirements)

- PHP `^8.2`
- IBM i 7.2 or later (for `Schema::dropIfExists()`)
- Laravel 12 (`illuminate/* ^12.0`) — this version supports **exclusively** Laravel 12, see [CHANGELOG.md](CHANGELOG.md)
- PHP PDO\_ODBC extension
- IBM i Access ODBC Driver ([Windows &amp; Linux](https://ibmi-oss-docs.readthedocs.io/en/latest/odbc/installation.html))

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

[](#installation)

Install the package via composer:

```
composer require beryildiz/db2-driver
```

Add a new connection in `database.php`:

> Note: You can specify the connection name, but the driver must be 'db2'

```
'myDB2Connection' => [
    'driver'        => 'db2',
    'driverName'    => '{IBM i Access ODBC Driver}',
    'host'          => env('DB_HOST'),
    'username'      => env('DB_USERNAME'),
    'password'      => env('DB_PASSWORD'),
    'database'      => env('DB_DATABASE'),
    'prefix'        => '',
    'schema'        => env('DB_SCHEMA'),
    'port'          => env('DB_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'
    'offset_compatibility_mode' => true,
    'odbc_keywords' => [
        // optional, see the full default list below
    ],
    'options' => [
        PDO::ATTR_CASE             => PDO::CASE_LOWER,
        PDO::ATTR_EMULATE_PREPARES => false,
        PDO::ATTR_PERSISTENT       => false,
    ]
],
```

> Note: Be sure to define the appropriate keys in `.env`.

`odbc_keywords` defaults (click to expand)```
'odbc_keywords' => [
    'SIGNON'                => 3,
    'SSL'                   => 0,
    'CommitMode'            => 0,
    'ConnectionType'        => 0,
    'DefaultLibraries'      => '',
    'Naming'                => 1,
    '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'       => 1,
    'QAQQINILibrary'        => '',
    'SQDIAGCODE'            => '',
    'LANGUAGEID'            => 'ENU',
    'SORTTABLE'             => '',
    'SortSequence'          => 0,
    'SORTWEIGHT'            => 0,
    'AllowUnsupportedChar'  => 0,
    'CCSID'                 => 1208,
    '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,
],
```

See [DB2 Connection String Keywords](https://www.ibm.com/docs/fr/i/7.3?topic=details-connection-string-keywords)for what each key does.

Limitations
-----------

[](#limitations)

This driver targets the query builder and Eloquent. Schema/migration support is functional but deliberately narrow — DB2 for IBM i differs substantially from the databases Laravel ships drivers for. Everything listed below fails with an explicit exception rather than producing silently wrong SQL.

### Schema introspection — not supported

[](#schema-introspection--not-supported)

`Schema::getTables()`, `getViews()`, `getTypes()`, `getColumns()`, `getIndexes()`, `getForeignKeys()`, `getSchemas()` and therefore the `db:show` and `db:table` commands throw a `RuntimeException`. Use `Schema::hasTable()` and `Schema::getColumnListing()`, which are supported.

### Dropping everything — not supported

[](#dropping-everything--not-supported)

`Schema::dropAllTables()`, `dropAllViews()` and `dropAllTypes()` throw a `LogicException`, which means **`migrate:fresh` and `db:wipe` are unavailable**. DB2 for IBM i has no global foreign-key switch and no `DROP TABLE ... CASCADE`, so a partial implementation would fail halfway through and leave the schema in an undefined state. Use `migrate:refresh` (which runs your `down()` methods) instead.

### Other unsupported operations

[](#other-unsupported-operations)

OperationBehaviour`schema:dump`, `migrate --schema-path``BadMethodCallException` (no `getSchemaState()`)`Schema::withoutForeignKeyConstraints()`not supported by DB2 for i`Schema::createDatabase()` / `dropDatabaseIfExists()``LogicException``upsert()`, `insertOrIgnore()``RuntimeException``inRandomOrder()`emits `RANDOM()`; DB2 for i uses `RAND()`JSON column operators (`where('col->key')`)`RuntimeException``DB::pretend()` / raw SQL in the query logunreliable — PDO\_ODBC does not implement `quote()`### Unsupported column types

[](#unsupported-column-types)

DB2 for IBM i has no equivalent that maps cleanly, so these throw a `BadMethodCallException`: `json`, `jsonb`, `ulid`, `tinyInteger`, `mediumInteger`, `tinyText`, `year`, `ipAddress`, `macAddress`, `set`, `geometry`, `vector`, `computed`.

Supported: `char`, `string`, `text`, `mediumText`, `longText`, `bigInteger`, `integer`, `smallInteger`, `numeric`, `float`, `double`, `decimal`, `boolean`, `enum`, `date`, `dateTime`, `time`, `timestamp`, `binary`, `uuid`.

### Requirements and caveats

[](#requirements-and-caveats)

- The `schema` key in your connection config is effectively **required** — `hasTable()` and `getColumnListing()` resolve unqualified table names against it.
- `Schema::dropIfExists()` emits `DROP TABLE ... IF EXISTS` and therefore needs **IBM i 7.2 or later**.
- `$table->index($columns, 'name')` honours the given index name. Releases before the Laravel 12 rewrite silently replaced it with a generated one, so index names may differ from what an older version of this package created.

Testing &amp; Contributing
--------------------------

[](#testing--contributing)

Issues and pull requests are welcome. Before opening a PR, make sure the following pass locally (all three are wired up as `composer` scripts and run in CI):

```
composer format    # vendor/bin/pint
composer analyse   # vendor/bin/phpstan analyse
composer test      # vendor/bin/pest
```

Since this package talks to a real IBM i host over ODBC, most tests are unit tests against mocked connections/grammars rather than integration tests — there is no CI database. If you find a case that isn't covered, a failing test is the most useful part of a bug report.

Other Resources
---------------

[](#other-resources)

- [DB2 Connection String Keywords](https://www.ibm.com/docs/fr/i/7.3?topic=details-connection-string-keywords)
- [PDO Attributes](https://www.w3resource.com/php/pdo/php-pdo.php)
- [ACS / IBM i Access Driver Release Notes](https://www.ibm.com/support/pages/ibm-i-access-acs-updates-pase)
- [Seiden Group](https://www.seidengroup.com/blog/)

Credits
-------

[](#credits)

- [cooperl22](https://github.com/cooperl22) — original author of `laravel-db2`.
- [BWICompanies](https://github.com/BWICompanies) — maintained the first fork this package is based on.
- [All contributors](../../contributors) across all three generations of this driver.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/97116763?v=4)[b-my](/maintainers/beryildiz)[@beryildiz](https://github.com/beryildiz)

---

Top Contributors

[![bennettblack](https://avatars.githubusercontent.com/u/51721783?v=4)](https://github.com/bennettblack "bennettblack (10 commits)")[![sluggern67](https://avatars.githubusercontent.com/u/57130207?v=4)](https://github.com/sluggern67 "sluggern67 (2 commits)")[![alanseiden](https://avatars.githubusercontent.com/u/5905791?v=4)](https://github.com/alanseiden "alanseiden (1 commits)")[![anchan42](https://avatars.githubusercontent.com/u/19514416?v=4)](https://github.com/anchan42 "anchan42 (1 commits)")[![beryildiz](https://avatars.githubusercontent.com/u/97116763?v=4)](https://github.com/beryildiz "beryildiz (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")

---

Tags

laraveldb2-driverBeryildiz

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/beryildiz-db2-driver/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.4M352](/packages/psalm-plugin-laravel)[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k107.5M1.6k](/packages/spatie-laravel-permission)[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M180](/packages/spatie-laravel-health)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M277](/packages/laravel-ai)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

24773.9k](/packages/harris21-laravel-fuse)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5222.6k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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