Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Turso 5 min read How-to mediumAdept

Building a RESTful API with PHP and SQLite

A minimal CRUD REST API in PHP can be built with Dumbo, a small Hono-inspired routing framework, and Turso's experimental HTTP-only PHP SDK for libSQL/SQLite. The walkthrough covers Composer setup, a users table schema, connecting via a DSN with database URL and auth token, and GET/POST/PUT/DELETE routes using parameterized queries, RETURNING clauses and dynamic SET clauses for partial updates. Testing uses PHP's built-in server and cURL. Production use still needs proper validation, authentication, CORS and error handling.

Related posts

  • Create a fast, performant admin UI with Retool and Turso

    Turso mediumAdept

    A Retool admin dashboard for an e-commerce mug store can read and write data in a Turso (libSQL) database through Turso's HTTP API, configured as a Retool REST API resource. The resource uses the database URL with https in place of libsql, plus a Bearer token header. Queries POST SQL statements, and a transform function maps the column/row response into objects for a Retool table. A form with a category select submits inserts, and a success handler refreshes the product list.

  • Mobile app prototyping with Quasar and SQLite

    Turso mediumAdept

    A recipe-book mobile prototype built with the Vue-based Quasar framework, backed by a local SQLite file accessed through a small Express server using the libSQL JavaScript client. Because libSQL is used for data access, the same server code can later point at Turso for production without source changes. The walkthrough covers creating the schema in the SQLite shell, writing GET/POST/DELETE routes (including json_group_array aggregation and batched inserts), and wiring Quasar pages to a Pinia store. A local SQLite file keeps development fully offline and makes the database easy to share or reuse in tests.

  • Announcing Laravel Support and PHP PDO Interface

    Turso mediumAdept

    Turso has released `libsql-laravel`, an official open-source Laravel adapter, along with a PHP PDO interface. Both are in technical preview. The adapter extends Laravel's SQLiteConnection, so existing SQLite-compatible code, Eloquent models, migrations and transactions work against local files or remote Turso databases. It replaces community drivers that needed custom PHP extensions but does require FFI to be enabled. A walkthrough builds a movie similarity search using `VectorCast`, the `vector` and `vectorIndex` migration helpers, and a `nearest` query builder method.

  • Write that blog… with Turso!

    Turso mediumAdept

    WriteThatBlog!, an aggregator of engineering blog posts tagged by writing pattern, is a single static HTML page on GitHub Pages that queries a replicated Turso database directly from the browser over HTTP, with no backend functions or proxies. A read-only auth token is deliberately embedded in the page because the data is public anyway. The schema is one five-column table, and content is managed with a small shell script around `turso db shell` that returns the ROWID, which makes later updates and deletes trivial.

  • Bringing SQLite to Vercel Functions with Turso

    Turso mediumAdept

    Turso's partial sync replicates a subset of SQLite database pages into Vercel Functions so reads run in-process with no network round-trip, while writes go to the remote Turso database for durability and consistency. On cold start the driver fetches the first 128 KiB of the SQLite file, then pulls further 128 KiB segments on demand into the ephemeral /tmp directory, so cold-start cost scales with the working set rather than total database size. The experimental @tursodatabase/vercel-experimental package also auto-provisions databases by name for database-per-tenant or per-agent-session patterns. It offers an optional local-write batching mode that trades consistency for lower write latency, and uses a waitUntil() safety net that pushes pending changes if close() is forgotten.

The quest for software engineering knowledge.

Look:
Layout: