PHPackages                             kalel1500/laravel-db2-raw - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kalel1500/laravel-db2-raw

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kalel1500/laravel-db2-raw
=========================

laravel-db2-raw is a simple helper to execute raw DB2 queries in Laravel.

v0.1.0-beta.1(5mo ago)09GPL-3.0-or-laterPHPPHP ^8.2

Since Dec 2Pushed 5mo agoCompare

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

READMEChangelogDependencies (2)Versions (3)Used By (0)

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

[](#laravel-db2-raw)

 [![Total Downloads](https://camo.githubusercontent.com/31aae4b01a1dbad0aee6ec83426c4c8ad778b931accf5cfab89caceee634562b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b616c656c313530302f6c61726176656c2d6462322d726177)](https://packagist.org/packages/kalel1500/laravel-db2-raw) [![Latest Stable Version](https://camo.githubusercontent.com/124612e136add4a9b1cf436e1b1cd94a408a6a51808373e25f16c0b66b8413a0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b616c656c313530302f6c61726176656c2d6462322d726177)](https://packagist.org/packages/kalel1500/laravel-db2-raw) [![License](https://camo.githubusercontent.com/341d4e530b61782cec2d5787dc552fcb2a70364cc4d16f27907ed4ecbfebad05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b616c656c313530302f6c61726176656c2d6462322d726177)](https://packagist.org/packages/kalel1500/laravel-db2-raw)

laravel-db2-raw is a simple helper to execute raw DB2 queries in Laravel.

This package provides a thin wrapper around the native `ibm_db2` functions (`db2_connect`, `db2_exec`, `db2_fetch_assoc`, `db2_close`) to make it easier to run raw DB2 SQL queries in Laravel without using Eloquent.

---

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

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

[](#installation)

### Requirements

[](#requirements)

- PHP &gt;= 8.2
- `ext-json`
- `ext-ibm_db2`
- Laravel &gt;= 12.x

### Installation

[](#installation-1)

Install laravel-db2-raw in your Laravel app with Composer:

```
composer require kalel1500/laravel-db2-raw
```

Configuration
-------------

[](#configuration)

The following environment variables are used by the default connection:

- `DB2RAW_CONNECTION`: Default logical connection name (e.g. `main`).
- `DB2RAW_HOST`: DB2 server hostname or IP.
- `DB2RAW_PORT`: DB2 server port.
- `DB2RAW_DATABASE`: DB2 database name.
- `DB2RAW_USERNAME`: Username used to connect.
- `DB2RAW_PASSWORD`: Password used to connect.

This is the default configuration file (`config/db2_raw.php`):

```

    /*
    |--------------------------------------------------------------------------
    | DB2 connections
    |--------------------------------------------------------------------------
    */

    'default' => env('DB2RAW_CONNECTION', 'main'),

    'connections' => [

        'main' => [
            'host' => env('DB2RAW_HOST'),
            'port' => env('DB2RAW_PORT'),
            'database' => env('DB2RAW_DATABASE'),
            'username' => env('DB2RAW_USERNAME'),
            'password' => env('DB2RAW_PASSWORD'),
        ]

    ]
```

You can also publish the configuration file (`config/db2_raw.php`) with the following command

```
php artisan vendor:publish --tag="db2raw"
```

Usage
-----

[](#usage)

### Basic

[](#basic)

To launch a query you can use the Db2 facade:

```
use Thehouseofel\DB2Raw\Facades\Db2;

Db2::exec($query)
```

The `exec` method receives the full SQL string and returns an array of associative arrays. Column names are normalized to lowercase. Currently, parameter binding (e.g. using `?`) is not supported: you must build the full SQL statement yourself.

Be careful when building SQL strings with user input to avoid SQL injection vulnerabilities.

### Defining additional connections

[](#defining-additional-connections)

You can also define additional connections in the configuration file:

```

    'connections' => [
        //...

        'admin' => [
            'host' => env('DB2RAW_ADMIN_HOST'),
            'port' => env('DB2RAW_ADMIN_PORT'),
            'database' => env('DB2RAW_ADMIN_DATABASE'),
            'username' => env('DB2RAW_ADMIN_USERNAME'),
            'password' => env('DB2RAW_ADMIN_PASSWORD'),
        ]

    ]
```

And before executing the query you can select which connection to use:

```
use Thehouseofel\DB2Raw\Facades\Db2;

Db2::connection('admin')->exec($query)
```

License
-------

[](#license)

laravel-db2-raw is open-sourced software licensed under the [GNU General Public License v3.0](LICENSE).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance73

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~6 days

Total

2

Last Release

154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4fe382001315cb114e9b5b04f43ee1eee86208e169c1369ab4f87353d96d73ea?d=identicon)[kalel1500](/maintainers/kalel1500)

---

Top Contributors

[![kalel1500](https://avatars.githubusercontent.com/u/43579076?v=4)](https://github.com/kalel1500 "kalel1500 (29 commits)")

---

Tags

laravelhelperpackagedb2queryraw

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)

PHPackages © 2026

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