Configuration
Publish the config file:
php artisan vendor:publish --tag="laravel-sql-parser-config"
Full reference
| Key |
Default |
Description |
default_dialect |
null (SQL_PARSER_DIALECT) |
Dialect used when none is given; null uses the default connection's driver |
error_level |
immediate (SQL_PARSER_ERROR_LEVEL) |
immediate, raise, warn or ignore |
pretty |
false |
Format transpiled SQL over several lines by default |
memo.enabled, memo.size |
false, 1000 |
Keep recent results in memory for the life of the process (Octane, queues) |
cache.enabled |
false (SQL_PARSER_CACHE) |
Store results in a Laravel cache store |
cache.store, cache.ttl, cache.prefix |
null, 86400, sql-parser: |
Which store, for how long, under which prefix |
cache.min_length |
2000 |
Statements shorter than this skip the cache |
dialects |
[] |
Custom dialects, name => class extending Dialects\Dialect |
macros |
true |
Register the query-builder macros |
Environment variables
SQL_PARSER_DIALECT=mysql
SQL_PARSER_ERROR_LEVEL=immediate
SQL_PARSER_MEMO=false
SQL_PARSER_CACHE=false
SQL_PARSER_CACHE_STORE=redis
Examples
Force a default dialect instead of inferring from the DB connection:
'default_dialect' => 'mysql',
Enable per-process memoization for Octane:
'memo' => ['enabled' => true, 'size' => 1000],
Cache long transpiles in Redis:
'cache' => [
'enabled' => true,
'store' => 'redis',
'ttl' => 86400,
'prefix' => 'sql-parser:',
'min_length' => 2000,
],
Register a custom dialect:
'dialects' => [
'mydialect' => App\Sql\MyDialect::class,
],