guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel įš„ SQL äŧ˜åŒ–器和重写器。

Maintainers

👁 guanguans

Package info

github.com/guanguans/laravel-soar

Type:laravel

pkg:composer/guanguans/laravel-soar

Fund package maintenance!

Sponsors

Statistics

Installs: 8 421

Dependents: 0

Suggesters: 0

Stars: 222

Open Issues: 0

6.0.1 2026-04-02 08:07 UTC

Requires

Requires (Dev)

Suggests

Provides

None

Conflicts

None

Replaces

None

This package is auto-updated.

Last update: 2026-06-24 14:38:35 UTC


README

👁 Image
👁 Image

laravel-soar

SQL optimizer and rewriter for laravel. - laravel įš„ SQL äŧ˜åŒ–器和重写器。

įŽ€äŊ“中文 | ENGLISH

👁 tests
👁 php-cs-fixer
👁 codecov
👁 Latest Stable Version
👁 GitHub release (with filter)
👁 Total Downloads
👁 License

Features

  • Supports heuristic rule suggestions, index rule suggestions, and EXPLAIN information interpretation
  • Support calling query builder Mixin methods for convenient dumping of rule suggestions
  • Automatically monitor output rule suggestions to configured outputs

Related Links

Requirement

  • PHP >= 8.2

Installation

composer require guanguans/laravel-soar --dev --ansi -v

Configuration

Publish files(optional)

php artisan vendor:publish --provider="Guanguans\\LaravelSoar\\SoarServiceProvider"

âš ī¸ When running in a unix OS non-cli environment, may throw Fatal error: ...Exit Code: 2(Misuse of shell builtins)

Configure sudo password

# Fatal error: Uncaught Guanguans\SoarPHP\Exceptions\ProcessFailedException: The command "'/Users/yaozm/Documents/develop/soar-php/bin/soar.darwin-amd64' '-report-type=json' '-query=select * from users;'" failed. Exit Code: 2(Misuse of shell builtins) Working directory: /Users/yaozm/Documents/develop/soar-php Output: ================ Error Output: ================ panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1938665] goroutine 1 [running]: github.com/pingcap/tidb/util/memory.MemTotalNormal() pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20210601085537-5d7c852770eb/util/memory/meminfo.go:41 +0x65 github.com/pingcap/tidb/util/memory.init.0() pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20210601085537-5d7c852770eb/util/memory/meminfo.go:134 +0x175 in /Users/yaozm/Documents/develop/soar-php/src/Concerns/WithRunable.php:36 Stack trace: #0 /Users/yaozm/Documents/develop/soar-php/test.php(163): Guanguans\SoarPHP\Soar->run() #1 /User in /Users/yaozm/Documents/develop/soar-php/src/Concerns/WithRunable.php on line 36
SOAR_SUDO_PASSWORD='your sudo password' # Set a sudo password to run the soar command with sudo to avoid the above errors.

Or configure sudoers

Usage

Enable to automatically output SQL optimization suggestions

Install and configure outputs(optional)

Soar commands

Soar facade and methods

Methods of the query builder Mixin

Composer scripts

composer checks:required
composer php-cs-fixer:fix
composer test
composer testbench soar:run
composer testbench soar:score
composer testbench:serve
composer testbench:test
composer testbench:user-serve

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.