upstash/vector-laravel is a dedicated Laravel SDK for Upstash Vector, that is built on top of our official PHP SDK.
By using upstash/vector-laravel you will be able to:
- Integrate Upstash Vector by only installing the package and setting environment variables.
- A native Vector facade to interact with your vector database.
- Able to maintain multiple index connections in your application.
You can find the Github Repository here.
Install#
To install the SDK, you can use composer:
Setup#
There are two pieces of configuration required to use the Upstash vector client: a REST token and REST URL. These values can be passed using environment variables or in code through the initialization of the Index. Find your configuration values in the console dashboard at https://console.upstash.com/.
Usage#
Our Laravel SDK will configure your index into the Laravel Service Container. You can access it by calling the Vector facade
or by injecting the IndexInterface into your controllers.
Vector Facade#
When these environment variables are set, you can start using your Index by calling the Vector facade.
Dependency Injection#
If you prefer to avoid using the facade, you can inject the IndexInterface into your controllers.
Configuration#
You can also configure the SDK to be able to use multiple indexes in your application.
For doing that you can publish the configuration file by running the following command:
You'll get a new file under config/vector.php that you can edit to add your indexes.
Multiple Connections#
If you want to use multiple connections in your application, you can add them to the connections array as shown below:
To access a specific connection, you can use the connection method: