Download the PHP package shimabox/laqu without Composer
On this page you can find all versions of the php package shimabox/laqu. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shimabox/laqu
More information about shimabox/laqu
Files in shimabox/laqu
Informations about the package laqu
Laqu
[ Japanese | English ]
Laqu is Laravel Db Query Helper.
Features
- 実行されたdbクエリを確認できます
- PHPUnit でのアサーション、実行時間による並べ替え、ビルド後のクエリのチェックなど
Attention
このライブラリは、開発中に利用されることを想定しています。
See Also
【Laravel】実行されたDBクエリの確認ができるやつを書いた - Qiita
Requirement
- PHP 7.4+ or newer(7.4, 8.0)
- Laravel
6.x
,7.x
,8.x
Installation
Via composer.
Develop.
Usage
QueryAssertion
期待するクエリが流れているかPHPUnitでアサーションするためのものです。
traitです。assertQuery()を使います。
QueryAnalyzer
クエリが流れるメソッドを渡して、どのようなクエリが流れたのか確認することができます。
QueryAnalyzer::analyze()
で実行されたクエリの結果(Laqu\Analyzer\QueryList
)が取得できます。
※ QueryListはLaqu\Analyzer\Query
を持ちます
Helper
QueryLog
QueryLogは Basic Database Usage - Laravel - The PHP Framework For Web Artisans の処理をラップしたものです。
※ 実行時間関連はそこまで精密ではありません
QueryHelper
クエリとバインドパラメータを渡すと、実行されるクエリの確認ができます。
pdo-debug/pdo-debug.php at master · panique/pdo-debug を参考にしています。
QueryFormatter
QueryFormatterはDoctrine\SqlFormatter\SqlFormatter
のラッパーです。
@see doctrine/sql-formatter: A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.
デフォルトはNullHighlighter
を利用していますが、CLI、HTMLでのフォーマットも可能です。
format()
デフォルトのHighlighterはDoctrine\SqlFormatter\NullHighlighter
です。
Doctrine\SqlFormatter\CliHighlighter
を利用する場合は以下の通り、CliHighlighter
をインジェクトしてください。
出力結果
Doctrine\SqlFormatter\HtmlHighlighter
を利用する場合は以下の通り、HtmlHighlighter
をインジェクトしてください。
出力結果
highlight()
使い方は format()
とほぼ同じです。
https://github.com/doctrine/sql-formatter#syntax-highlighting-only を参照してください。
compress()
compress()
はすべてのコメントと余計な空白を取り除いたクエリを返却します。
https://github.com/doctrine/sql-formatter#compress-query を参照してください。
Develop
Run php-cs-fixer.
check.
fix.
Run phpstan(larastan).
check.
Run test.
Run ci.
Run all the above commands at once.
TODO
テストで確認しているクエリのパターンがまだまだ少ないです。
All versions of laqu with dependencies
illuminate/support Version ^6.0|^7.0|^8.0|^9.0
doctrine/sql-formatter Version ^1.1