{"id":33984654,"url":"https://github.com/mharacewiat/eloquent-sql-dumper","last_synced_at":"2026-04-24T17:06:07.343Z","repository":{"id":62514844,"uuid":"171052193","full_name":"mharacewiat/eloquent-sql-dumper","owner":"mharacewiat","description":"Eloquent SQL dumper for Laravel","archived":false,"fork":false,"pushed_at":"2019-03-03T12:24:57.000Z","size":47,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-14T16:52:02.815Z","etag":null,"topics":["bindings","debug","debugging","eloquent","laravel","log","logging","macro","package","sql"],"latest_commit_sha":null,"homepage":"http://haracewiat.pl/2019/02/16/dump-eloquent-sql/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mharacewiat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-16T21:08:38.000Z","updated_at":"2023-08-12T19:55:49.000Z","dependencies_parsed_at":"2022-11-02T10:17:19.049Z","dependency_job_id":null,"html_url":"https://github.com/mharacewiat/eloquent-sql-dumper","commit_stats":null,"previous_names":["haru0/eloquent-sql-dumper"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mharacewiat/eloquent-sql-dumper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mharacewiat%2Feloquent-sql-dumper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mharacewiat%2Feloquent-sql-dumper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mharacewiat%2Feloquent-sql-dumper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mharacewiat%2Feloquent-sql-dumper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mharacewiat","download_url":"https://codeload.github.com/mharacewiat/eloquent-sql-dumper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mharacewiat%2Feloquent-sql-dumper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32232710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindings","debug","debugging","eloquent","laravel","log","logging","macro","package","sql"],"created_at":"2025-12-13T04:36:18.549Z","updated_at":"2026-04-24T17:06:07.306Z","avatar_url":"https://github.com/mharacewiat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/Haru0/eloquent-sql-dumper.svg?style=svg)](https://circleci.com/gh/Haru0/eloquent-sql-dumper) \n[![SymfonyInsight](https://insight.symfony.com/projects/435fee6e-6c83-4fc0-a49e-5a6b6ffef2a6/mini.svg)](https://insight.symfony.com/projects/435fee6e-6c83-4fc0-a49e-5a6b6ffef2a6)\n\n## Eloquent SQL dumper\n\nThis **Laravel package** introduces simple service for **dumping** SQL with binded values.\n\nThis repository originated from [my personal blog](http://haracewiat.pl/2019/02/16/dump-eloquent-sql/), and aims to briefly explain advantages of Laravel's `Illuminate\\Support\\Traits\\Macroable`.\n\n## Features\n\nDelivered `Haru0\\EloquentSqlDumper\\ServiceProvider` registers a `dump` macro on `Illuminate\\Database\\Query\\Builder` which then could be then used for **logging** and **debugging**.\n\nAlthough, you will be fine, I strongly discourage you from using this library on production for logging purposes. I believe it's not the proper way for this, and you should seek for dedicated logging solution.\n\n## Installation\n\n```bash\ncomposer require --dev haru0/eloquent-sql-dumper\n```\n\nThis package supports **package-discovery** and can be used straight away after adding to the Composer's dependencies.\n\nIf your project disables package-discovery feature, it is necessary to manually register `Haru0\\EloquentSqlDumper\\ServiceProvider`. This can be done by adding this line below, inside `config/app.php` file.\n\n```php\n/*\n * Package Service Providers...\n */\nHaru0\\EloquentSqlDumper\\ServiceProvider::class,\n```\n\nNo configuration options available.\n\n## Usage\n\n`Haru0\\EloquentSqlDumper\\Services\\DumperService`, once registered, can be basically used anywhere. It is also easily **overrideable** and **extensible**.\n\nExample `routes/web.php` file:\n\n```php\nuse Illuminate\\Database\\Query\\Builder;\nuse Illuminate\\Support\\Facades\\DB;\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::get('/', function () {\n    $query = DB::query()\n        -\u003efrom('users')\n        -\u003ewhere('active', true)\n        -\u003ewhere(function (Builder $builder) {\n            $builder\n                -\u003eorWhere('email', 'like', '%gmail.com')\n                -\u003eorWhere('email', 'like', '%example.com');\n        })\n        -\u003eorderByDesc('id')\n        -\u003elimit(10);\n\n    dd($query-\u003edump());\n});\n```\n\n`Tinker` version, for **REPL** lovers:\n\n```bash\nPsy Shell v0.9.9 (PHP 7.3.2-3+ubuntu18.04.1+deb.sury.org+1 — cli) by Justin Hileman\n\u003e\u003e\u003e DB::query() \\\n...     -\u003efrom('users') \\\n...     -\u003ewhere('active', true) \\\n...     -\u003ewhere(function ($builder) { \\\n...         $builder \\\n...             -\u003eorWhere('email', 'like', '%gmail.com') \\\n...             -\u003eorWhere('email', 'like', '%example.com'); \\\n...     }) \\\n...     -\u003eorderByDesc('id') \\\n...     -\u003elimit(10) \\\n...     -\u003edump()\n=\u003e \"select * from `users` where `active` = 1 and (`email` like '%gmail.com' or `email` like '%example.com') order by `id` desc limit 10\"\n```\n\n## Overriding and extending \n\nIf you need to adjust or override `Haru0\\EloquentSqlDumper\\Services\\DumperService` functionality, you're welcome to either **bind implementation to the contract**, or **register listener** to the two events dispatched by the service. \n\nDepending on your needs, one of the ways of customizing `dump` macro, is to write your own `DumperService` and bind it to the `Haru0\\EloquentSqlDumper\\Contracts\\DumperContract`.\n\n```php\nuse App\\Services\\MyDumper;\nuse Haru0\\EloquentSqlDumper\\Contracts\\DumperContract;\n\n$this-\u003eapp-\u003ebind(DumperContract::class, MyDumper::class);\n```\n\nOther way of customizing `dump` macro is to register a [listener](https://laravel.com/docs/5.7/events#defining-listeners) or [subscriber](https://laravel.com/docs/5.7/events#event-subscribers) to the `Haru0\\EloquentSqlDumper\\Events\\AfterDumpEvent` and `Haru0\\EloquentSqlDumper\\Events\\BeforeDumpEvent` events. \n\nFinally, you can modify macro name (in case it collides with existing one). To do so, adjust configuration option or put `ELOQUENT_SQL_DUMPER_MACRO` environment variable into your `.env` file.\n\n```dotenv\nELOQUENT_SQL_DUMPER_MACRO=foo_bar_baz\n```\n\n\u003e You can change that environment by overriding configuration file. Do do so, you need to publish package configuration file `php artisan vendor:publish --provider=Haru0\\EloquentSqlDumper\\ServiceProvider`. \n\nThen, use it the same way `dump` was shown in the [Usage](#Usage) chapter.\n\n\u003e Macro name is **always** casted to [Camel case](https://en.wikipedia.org/wiki/Camel_case). In this example above, your macro will be executed by `$query-\u003efooBarBaz`.\n\n## Contribute\n\nAny contribution is welcome. Fork this repository and create a pull request. Please remember to provide brief description.\n\n[Here you can find all contributors](https://github.com/Haru0/eloquent-sql-dumper/graphs/contributors).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmharacewiat%2Feloquent-sql-dumper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmharacewiat%2Feloquent-sql-dumper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmharacewiat%2Feloquent-sql-dumper/lists"}