Skip to content

Commit de93f50

Browse files
authored
Merge pull request #189 from alpha0010/patch-1
2 parents 93f1208 + 787b6a2 commit de93f50

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,36 @@ $query = (new Percolate($conn))
532532

533533
Execute the `CALL PQ`.
534534

535+
## Laravel
536+
537+
Laravel's dependency injection and realtime facades brings more convenience to SphinxQL Query Builder usage.
538+
539+
```php
540+
// Register connection:
541+
use Foolz\SphinxQL\Drivers\ConnectionInterface;
542+
use Foolz\SphinxQL\Drivers\Mysqli\Connection;
543+
use Illuminate\Support\ServiceProvider;
544+
545+
class AppServiceProvider extends ServiceProvider
546+
{
547+
public function register()
548+
{
549+
$this->app->singleton(ConnectionInterface::class, function ($app) {
550+
$conn = new Connection();
551+
$conn->setParams(['host' => 'domain.tld', 'port' => 9306]);
552+
return $conn;
553+
});
554+
}
555+
}
556+
557+
// In another file:
558+
use Facades\Foolz\SphinxQL\SphinxQL;
559+
560+
$result = SphinxQL::select('column_one', 'colume_two')
561+
->from('index_ancient', 'index_main', 'index_delta')
562+
->match('comment', 'my opinion is superior to yours')
563+
->where('banned', '=', 1)
564+
->execute();
565+
```
566+
567+
Facade access also works with `Helper` and `Percolate`.

0 commit comments

Comments
 (0)