PHPackages                             arnoldfederis/builder-to-sql - 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. arnoldfederis/builder-to-sql

ActiveLibrary

arnoldfederis/builder-to-sql
============================

Render Eloquent or Query builder to Sql

14.2k↓100%PHP

Since Jul 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/arnoldfederis/builder-to-sql)[ Packagist](https://packagist.org/packages/arnoldfederis/builder-to-sql)[ RSS](/packages/arnoldfederis-builder-to-sql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Builder to SQL
----------------------

[](#laravel-builder-to-sql)

Description
-----------

[](#description)

Render Eloquent or Query builder to Sql.

In this package will automatically replace all `?` from `toSql()` result with your bindings.

This is useful when you don't want to manual query.

Compatibility
-------------

[](#compatibility)

`Laravel 5 to latest version`

`PHP ^7.0`

How to install
--------------

[](#how-to-install)

```
composer require arnoldfederis/builder-to-sql

```

How to use
----------

[](#how-to-use)

Import BuilderToSql class or use the helper function.

```
class TestController extends Controller
{
    public function index()
    {
        /* Class base */
        // Query Builder
        return BuilderToSql::render(DB::table('users')->where('email', 'query_builder_to_sql@email.com')->orderByDesc('created_at'));

        // Eloquent Builder
        return BuilderToSql::render(User::where('email', 'query_builder_to_sql@email.com')->orderByDesc('created_at'));

        /* Function base */
        // Query Builder
        return query_builder_to_sql(DB::table('users')->where('email', 'query_builder_to_sql@email.com')->orderByDesc('created_at'));

        // Eloquent Builder
        return query_builder_to_sql(User::where('email', 'query_builder_to_sql@email.com')->orderByDesc('created_at'));

        // Result
        // select * from users where email = 'query_builder_to_sql@email.com' order by created_at desc
    }
}
```

License
-------

[](#license)

This is a free software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f7de56c27626968698517b3aa0585588c50a64af107e25555a958e23ec4d3ab8?d=identicon)[arnoldfederis](/maintainers/arnoldfederis)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/arnoldfederis-builder-to-sql/health.svg)

```
[![Health](https://phpackages.com/badges/arnoldfederis-builder-to-sql/health.svg)](https://phpackages.com/packages/arnoldfederis-builder-to-sql)
```

PHPackages © 2026

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