Skip to content

Instantly share code, notes, and snippets.

@hkulekci
Created February 24, 2024 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkulekci/c113012a865161b88eaa70dc7da89f25 to your computer and use it in GitHub Desktop.
Save hkulekci/c113012a865161b88eaa70dc7da89f25 to your computer and use it in GitHub Desktop.
Qdrant Laravel
<?php
return [
'host' => env('QDRANT_HOST', 'http://127.0.0.1:6333'),
'api_key' => env('QDRANT_API_KEY', null),
];
<?php
/**
* @since Apr 2023
* @author Haydar KULEKCI <haydarkulekci@gmail.com>
*/
namespace App\Providers;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
use Qdrant\Config;
use Qdrant\Http\GuzzleClient;
use Qdrant\Qdrant;
class QdrantServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register(): void
{
$this->app->singleton('qdrant.connection', function ($app) {
$config = new Config(config('qdrant.host'));
if (config('qdrant.api_key')) {
$config->setApiKey(config('qdrant.api_key'));
}
return new GuzzleClient($config);
});
$this->app->singleton(Qdrant::class, function ($app) {
return new Qdrant($app['qdrant.connection']);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides(): array
{
return [Qdrant::class, 'qdrant.connection'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment