# Surqlize

Surqlize is an object-relational mapper for SurrealDB in PHP, built on version 2 of the SDK, with attribute-driven models, a typed query builder, graph relations, and schema tooling.

[Surqlize](https://github.com/surrealdb/surqlize.php) is an object-relational mapper for SurrealDB in PHP. You describe tables as PHP classes with attributes, then compose SurrealQL through a typed query builder instead of writing strings. It is built on top of [version 2 of the SDK](/docs/reference/php/v2.md) and uses the SDK to execute queries.

The core idea is small: describe your SurrealDB tables with models and attributes, then build queries through typed PHP APIs that your IDE and static analyser understand. Surqlize compiles each query to a deterministic SurrealQL string for tests, and runs it through the SDK with parameter-bound values at runtime.

> [!IMPORTANT]
> Surqlize is published as `0.0.1-alpha.2` and is in early development. It requires PHP `8.4` and depends on the alpha [v2 SDK](/docs/reference/php/v2.md), so its API may change.

## Getting started

- [Installation](/docs/reference/php/libraries/surqlize/installation.md) - Install Surqlize with Composer and the alpha SDK it depends on.

- [Models](/docs/reference/php/libraries/surqlize/models.md) - Describe tables as PHP classes with attribute-driven fields.

- [Connections](/docs/reference/php/libraries/surqlize/connections.md) - Register an SDK executor and inject one per query when needed.

## Building queries

- [Querying](/docs/reference/php/libraries/surqlize/querying.md) - Typed select, where, ordering, projections, and the execution methods.

- [Mutations](/docs/reference/php/libraries/surqlize/mutations.md) - Create, update, upsert, and delete with model helpers and builders.

- [Edges and graph](/docs/reference/php/libraries/surqlize/edges-and-graph.md) - Edge models, graph traversal, and RELATE.

- [Search, vector, and geometry](/docs/reference/php/libraries/surqlize/search-vector-geometry.md) - Full-text search, vector KNN, and geometry helpers.

## Schema and tooling

- [Schema](/docs/reference/php/libraries/surqlize/schema.md) - Define tables with a schema contract or the fluent DSL.

- [Code generation and CLI](/docs/reference/php/libraries/surqlize/code-generation-and-cli.md) - Generate typed field adapters and run the CLI commands.

- [Transactions](/docs/reference/php/libraries/surqlize/transactions.md) - Batch ORM queries into a single transaction with rollback.

## Sources

- [GitHub repository](https://github.com/surrealdb/surqlize.php)
- [PHP SDK v2](/docs/reference/php/v2.md) that Surqlize builds on
- [Laravel integration](/docs/reference/php/frameworks/laravel.md) for using Surqlize in Laravel
