Sqlcommenter is a plugin/middleware/wrapper to augment SQL statements from laravel with comments that can be used later to correlate user code with SQL statements.
composer require "google/sqlcommenter-laravel"
Publish the config file from library to into laravel app using below command
php artisan vendor:publish --provider="Google\GoogleSqlCommenterLaravel\GoogleSqlCommenterServiceProvider"
Add the following class above Illuminate\Database\DatabaseServiceProvider::class
,
in config/app.php
'providers' => [
...
Google\GoogleSqlCommenterLaravel\Database\DatabaseServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
...
]
With Laravel SqlCommenter, we have configuration to choose which tags to be appended to the comment. It is configurable in config/google_sqlcommenter.php
Field | Included by default? |
Description |
---|---|---|
action |
✔ |
The application namespace of the matching URL pattern in your routes/api.php |
controller |
✔ |
The name of the matching URL pattern as described in your routes/api.php |
db_driver |
✔ |
The name of the php database engine |
framework |
✔ |
The word "laravel" and the version of laravel being used |
route |
✔ |
The route of the matching URL pattern as described in your routes/api.php |
traceparent |
✔ |
The W3C TraceContext.Traceparent field of the OpenTelemetry trace |