PHPackages                             zjkiza/sql-blade - 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. zjkiza/sql-blade

ActiveLaravel-package[Database &amp; ORM](/categories/database)

zjkiza/sql-blade
================

The packages executes raw SQL queries with the flexibility to embed Blade extensions, enabling the dynamic creation of queries using Blade syntax.

v0.5.6(3mo ago)29MITPHPPHP &gt;=8.0

Since May 14Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/zjkiza/sql-blade)[ Packagist](https://packagist.org/packages/zjkiza/sql-blade)[ RSS](/packages/zjkiza-sql-blade/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (13)Versions (8)Used By (0)

Sql Blade Package
=================

[](#sql-blade-package)

The packages execute raw SQL queries which are in a separate file with the flexibility to embed Blade extensions, enabling the dynamic creation of queries using Blade syntax.

About the package
=================

[](#about-the-package)

- You can use Blade syntax when creating queries.
- You place queries in separate files. (Ex: `select_user.blade.sql`).
- Execute your queries using `Zjk\SqlBlade\Contract\SqlBladeInterface` service.
- Result of execution `Zjk\SqlBlade\Contract\SqlBladeInterface->executeQuery(..)` is instance of Doctrine\\DBAL\\Driver\\Result, use their methods to get results.
- Query execution via transaction `Zjk\SqlBlade\Contract\SqlBladeInterface->transaction(..)`

Installation
============

[](#installation)

Add `zjkiza/sql-blade` to your composer.json file:

```
composer require zjkiza/sql-blade

```

A quick example
===============

[](#a-quick-example)

Working with the bundle
-----------------------

[](#working-with-the-bundle)

It is necessary to define which directory/directories will be used for storing files with sql queries.

In file `config/view.php` add paths

Example:

```

    'paths' => [
        ...
        app_path('Sql/User'),
        ..
    ],
```

Create a sql query (to the directory defined above). Example (`select_user.blade.sql`):

```
# file select_user.blade.sql

SELECT u.id, u.email FROM users u
WHERE 1

@isset($emails)
    AND u.email IN ( :emails )
@endif

@isset($ids)
  AND u.id IN ( :ids )
@endif

ORDER BY
    @isset($ids)
        u.id
    @else
        u.email
    @endisset
;
```

Notice: At the end of the query, you must put `;`

Working in php, Example:

```
namespace App\Example;

use Zjk\SqlBlade\Contract\SqlBladeInterface;
use Doctrine\DBAL\Result;

class MyRepository {

    private SqlTwigInterface $sqlBlade;

    public function __construct(SqlBladeInterface $sqlBlade)
    {
        $this->sqlBlade = $sqlBlade;
    }

    public function users(): array
    {
        return $this->sqlBlade->executeQuery('select_user', [
                'emails' => ['foo@example.com', 'bar@example.com']
               ],[
                 'emails' => ArrayParameterType::STRING,
              ])->fetchAllAssociative()
    }

    public function withTransaction(): array
    {
        $result = $this->sqlBlade->transaction(function (SqlBladeInterface $sqlBlade): Result {
            return $sqlBlade->executeQuery('select_without_blade');
        }, TransactionIsolationLevel::READ_UNCOMMITTED);

        return $result->fetchAllAssociative();
    }
}
```

Crafting intricate and sophisticated queries.
---------------------------------------------

[](#crafting-intricate-and-sophisticated-queries)

At times, it's essential to have the flexibility to construct your queries in accordance with the logic of your application. This is where the sqlBlade comes into play, leveraging Blade to pre-parse all your query resources. This enables you to dynamically shape your queries as needed.

Query logging
=============

[](#query-logging)

Executed queries are logged in `laravel.log` file. In which there are:

- file name,
- sql query that was executed,
- arguments,
- argument types,
- query execution time in sec.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance82

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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 ~107 days

Recently: every ~155 days

Total

7

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ff452349a91001f15f3a1d5ddf5a3a7382218f9222bc3fbfdd005d6c5f0473c?d=identicon)[zjkiza](/maintainers/zjkiza)

---

Top Contributors

[![zjkiza](https://avatars.githubusercontent.com/u/31966449?v=4)](https://github.com/zjkiza "zjkiza (9 commits)")

###  Code Quality

Static AnalysisPHPStan, Psalm, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zjkiza-sql-blade/health.svg)

```
[![Health](https://phpackages.com/badges/zjkiza-sql-blade/health.svg)](https://phpackages.com/packages/zjkiza-sql-blade)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[kreait/laravel-firebase

A Laravel package for the Firebase PHP Admin SDK

1.3k16.5M42](/packages/kreait-laravel-firebase)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)

PHPackages © 2026

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