PHPackages                             phpcodemaker/cake-debug-query - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. phpcodemaker/cake-debug-query

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

phpcodemaker/cake-debug-query
=============================

Query Debugger in CakePHP

v1.0.1(4y ago)015MITPHP

Since May 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/phpcodemaker/cake-debug-query)[ Packagist](https://packagist.org/packages/phpcodemaker/cake-debug-query)[ RSS](/packages/phpcodemaker-cake-debug-query/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

cake-debug-query
================

[](#cake-debug-query)

### Debug Query in CakePHP

[](#debug-query-in-cakephp)

This is a development support code and not the complete package. The method in the Query.php under src folder can be copied to /vendor/cakephp/cakephp/src/Database/Query.php Class.

### Note

[](#note)

If There is a new update from CakePHP Database Query then the changes you made will be lost.

### Dependency

[](#dependency)

Make sure the dependency for this debugQuery($formatSQL = true) method jdorn/sql-formatter is available in vendor. You can install this dependency using this link .

### How to use in code?

[](#how-to-use-in-code)

Place the debugQuery($formatSQL = true) method as follows inside file

```

public function debugQuery($formatSQL = true): string
{
	  $query = $this->sql();
	  $placeholderArray = $this->getValueBinder()->bindings();
	  if (null != $placeholderArray) {
		  foreach ($placeholderArray as $placeholder => $paramArray) {
			  switch ($paramArray['type']) {
				  case 'json' :
					  $QueryParam[substr($placeholder, 1)] = '\'' . json_encode($paramArray['value'], JSON_NUMERIC_CHECK) . '\'';
					  break; case 'boolean':
				  case 'integer':
					  $QueryParam[substr($placeholder, 1)] = $paramArray['value'];
					  break;
				  case 'string':
				  case 'text' :
				  default :
					  $QueryParam[substr($placeholder, 1)] = "'{$paramArray['value']}'";
					  break;
		     }
		 }
	  }
	  $outputQuery = $query;
	  if (!empty($QueryParam)) {
		  $outputQuery = \Cake\Utility\Text::insert($query, $QueryParam);
	  }
	  return $formatSQL ? \SqlFormatter::format($outputQuery) : $outputQuery;
}

```

`

###### SQL with Formatted view Within Controller

[](#sql-with-formatted-view-within-controller)

```

$this->loadModel('Model);
print $this->Model
		 ->find()
		 ->select(["select_column"])
		 ->where(["user_id" => 1])
		 ->debugQuery()

```

\[output\]

```
SELECT
    Panels.panel AS Panels__panel,
    Panels.element AS Panels__element
FROM
    panels Panels

```

###### SQL without Formatting view Within Controller

[](#sql-without-formatting-view-within-controller)

```

$this->loadModel('Model);
$this->Model
	 ->find()
	 ->select(["select_column"])
	 ->where(["user_id" => 1])
	 ->debugQuery(false)

```

\[output\]

```
SELECT Panels.panel AS Panels__panel, Panels.element AS Panels__element FROM panels Panels

```

\[Note\]
While using dd() in web, Logging(i.e. \\Cake\\Log\\Log::debug()) and CLI for debugging purpose use formatSQL flag false as follows,
otherwise debugQuery returns HTML which you can't see the SQL in readable format.

dd($this-&gt;Model-&gt;find()-&gt;where()-&gt;debugQuery(false));

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

2

Last Release

1815d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/25471bf62e924ce552fa03781d555b427dd478b4f414f37c930b01f99c90a026?d=identicon)[phpcodemaker](/maintainers/phpcodemaker)

---

Top Contributors

[![phpcodemaker](https://avatars.githubusercontent.com/u/921868?v=4)](https://github.com/phpcodemaker "phpcodemaker (5 commits)")

---

Tags

cakephp3 sql debuggercakephp3 query debuggercakephp3 debug sqlcakephp3 debug querycakephp3 debug sql querycakephp4 sql debuggercakephp4 query debuggercakephp4 debug sqlcakephp4 debug querycakephp4 debug sql query

### Embed Badge

![Health badge](/badges/phpcodemaker-cake-debug-query/health.svg)

```
[![Health](https://phpackages.com/badges/phpcodemaker-cake-debug-query/health.svg)](https://phpackages.com/packages/phpcodemaker-cake-debug-query)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)[beyondcode/helo-laravel

HELO Laravel debug helper

90360.1k](/packages/beyondcode-helo-laravel)

PHPackages © 2026

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