Skip to content

Commit 3ae1941

Browse files
committed
Started Doctrine docs [skip ci]
1 parent 91c19dc commit 3ae1941

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[pgvector](https://github.com/pgvector/pgvector) support for PHP
44

5-
Supports [Laravel](https://github.com/laravel/laravel) and [PgSql](https://www.php.net/manual/en/book.pgsql.php)
5+
Supports [Laravel](https://github.com/laravel/laravel), [Doctrine](https://github.com/doctrine/orm), and [PgSql](https://www.php.net/manual/en/book.pgsql.php)
66

77
[![Build Status](https://github.com/pgvector/pgvector-php/actions/workflows/build.yml/badge.svg)](https://github.com/pgvector/pgvector-php/actions)
88

@@ -11,6 +11,7 @@ Supports [Laravel](https://github.com/laravel/laravel) and [PgSql](https://www.p
1111
Follow the instructions for your database library:
1212

1313
- [Laravel](#laravel)
14+
- [Doctrine](#doctrine) [unreleased]
1415
- [PgSql](#pgsql)
1516

1617
Or check out some examples:
@@ -108,6 +109,41 @@ public function down()
108109

109110
Use `vector_ip_ops` for inner product and `vector_cosine_ops` for cosine distance
110111

112+
### Doctrine
113+
114+
Install the package
115+
116+
```sh
117+
composer require pgvector/pgvector
118+
```
119+
120+
Update your model
121+
122+
```php
123+
use Pgvector\Vector;
124+
125+
#[ORM\Entity]
126+
class Item
127+
{
128+
#[ORM\Column(type: 'vector', length: 3, nullable: true)]
129+
private ?Vector $embedding;
130+
131+
public function setEmbedding(?Vector $embedding): void
132+
{
133+
$this->embedding = $embedding;
134+
}
135+
}
136+
```
137+
138+
Insert a vector
139+
140+
```php
141+
$item = new Item();
142+
$item->setEmbedding(new Vector([1, 2, 3]));
143+
$entityManager->persist($item);
144+
$entityManager->flush();
145+
```
146+
111147
### PgSql
112148

113149
Enable the extension

0 commit comments

Comments
 (0)