Rust

Appwrite is moving to Rust, one crate at a time.

Appwrite is built on Utopia, its open-source PHP libraries. Each is being rewritten as a Rust crate, and Appwrite's PHP extension serves the crate in place of the PHP it replaces. The crates stand on their own too: use one in any Rust project.

Utopia libraries with a Rust crate
15 / 52
PHP classes Appwrite runs from Rust
215
lines of Rust
206,511
$cargo add utopia-user-agent
1 PLATFORM · 8 PRODUCTS · 32 SERVICES · 13 CRATES
Assembled
Rustmain.rs
use utopia_user_agent::UserAgent;

let agent = UserAgent::parse(
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.127 Safari/537.36",
);
let client = agent.client();

assert!(client.is_browser());
assert_eq!(client.name.as_deref(), Some(&b"Chrome"[..]));
assert_eq!(client.version.as_deref(), Some(&b"126.0"[..]));
PHPindex.php
use Utopia\UserAgent\UserAgent;

$agent = UserAgent::parse('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.127 Safari/537.36');
$client = $agent->client();

var_dump($client->isBrowser()); // bool(true)
echo $client->name, "\n";      // Chrome
echo $client->version, "\n";   // 126.0
One user-agent parser, called from Rust and from PHP. In Appwrite the PHP call runs the Rust crate through the extension.
  1. 01

    One problem per crate

    Depend on a DSN parser without pulling in an image library. Each crate is small and documents its own API.

  2. 02

    Same API as PHP

    Each crate keeps the shape of its Utopia PHP library, so code and knowledge move across with it.

  3. 03

    Examples that run

    Every guide example is a complete program, compiled and run in CI, so what you copy works.

  4. 04

    Running in Appwrite

    Appwrite's PHP extension serves these crates as the PHP classes Appwrite already calls, under its full test suite.

The libraries are moving from PHP to Rust one at a time. Appwrite loads each Rust crate through its PHP extension, so the classes keep their PHP names and the PHP source is deleted.

From PHP to Rust15 of 52 libraries on Rust

215 PHP classes are served from Rust, in 206,511 lines of Rust (160,479 code). 1,043 classes and 147,664 lines are still PHP.

Rust 9Partly Rust 7Rust, switchable 0PHP 37
53 of 53 libraries

01Servers#

Serving requests and running work: the HTTP framework and its request and response values, WebSockets, DNS and MQTT brokers, job queues and schedules, and the base for building servers.

DNSutopia-php/dns
PHP

Lite & fast micro PHP DNS server abstraction that is **easy to use**.

HTTPutopia-php/http
PHP

A simple, light and advanced PHP HTTP framework

MQTTutopia-php/mqtt
PHP

A simple abstraction for building MQTT 5.0 brokers.

PSR-7utopia-php/psr7
PHP

PSR-7 HTTP message implementations and PSR-17 factories for Utopia

Scheduleutopia-php/schedule
PHP

An opinionated scheduler that reconciles schedules from a source of truth and dispatches cron, interval, delayed and fixed-time occurrences without silently skipping a run

Serversutopia-php/servers
PHP

A base library for building Utopia style servers.

Websocketutopia-php/websocket
PHP

A simple abstraction for WebSocket servers.

About servers →

02Transport#

Reaching other services: HTTP and SMTP clients, NATS, and connection strings.

Clientutopia-php/client
PHP

A lightweight PSR-18 HTTP client with cURL and Swoole coroutine backends

DSNutopia_dsn
Rust

Data source names (connection strings), parsed into scheme, credentials, host, port, path and options.

16 items21 examples1 PHP classes696 lines
NATSutopia-php/nats
PHP

Modern PHP client for NATS messaging system

Queueutopia_queue
Rust

Queue consumers that share queues with utopia-php/queue: a JetStream worker that reads, settles and dead-letters the way Broker\Nats does.

12 items4 examples1.8k lines
SMTPutopia-php/smtp
PHP

Lite & fast micro PHP SMTP library that is easy to learn

About transport →

03Data#

Keeping data: databases and the queries over them, caches and file storage.

About data →

04Security#

Who is calling and how often: password hashing, sessions, tokens, OAuth2 and passkeys, and abuse limits.

About security →

05Observability#

Seeing what a service does: audit trails, telemetry, tracing spans and usage metrics.

Auditutopia-php/audit
PHP

A simple audit library to manage application users logs

Spanutopia_span
Rust

Span tracing: attributes on the current span of each task, W3C trace context, and exporters to stdout, a terminal and Sentry.

140 items26 examples2.4k lines
Telemetryutopia-php/telemetry
PHP

A lite & fast telemetry library, with adapters for OpenTelemetry

Usageutopia-php/usage
PHP

Light and Fast Usage library

About observability →

06Platform#

The ground a service runs on: CLIs and consoles, configuration, dependency injection and registries, system information, locks, pools, circuit breakers, events, and the PHP engine semantics the Rust crates share.

Asyncutopia-php/async
PHP

High-performance concurrent + parallel library with Promise and Parallel execution support for PHP.

Busutopia-php/bus
PHP

Synchronous in-process event bus with typed events and listeners

Circuit breakerutopia-php/circuit-breaker
PHP

Light & simple Circuit Breaker for PHP to prevent cascading failures in distributed systems.

CLIutopia-php/cli
PHP

A simple CLI library to manage command line applications

Configutopia-php/config
PHP

A simple Config library to managing application config variables

Consoleutopia-php/console
PHP

Console helpers for logging, prompting, and executing commands

DIutopia-php/di
PHP

A simple and lite library for managing dependency injections

Lockutopia-php/lock
PHP

A simple lock library to coordinate access to shared resources across coroutines, processes and hosts

PHP standard libraryutopia_php_std
Rust

PHP engine semantics (the value model, juggling and comparison, string, number, JSON, serialize, igbinary, sorting, filter and URL functions) for crates that must behave exactly like PHP.

539 items20 examples40k lines
Platformutopia-php/platform
PHP

Light and Fast Platform Library

Poolsutopia-php/pools
PHP

A simple library to manage connection pools

Registryutopia-php/registry
PHP

A simple dependency management library for PHP

Systemutopia-php/system
PHP

A simple library for obtaining information about the host's system.

About platform →

07Utilities#

Focused helpers: input validation, translations, domain and email parsing, user-agent and device detection, OpenAPI documents, compression, load balancing and image processing.

Balancerutopia_balancer
Rust

Choosing between endpoints: options with state, filters, and the First, Last, Random and RoundRobin algorithms.

45 items10 examples8 PHP classes704 lines
Compressionutopia_compression
Rust

Compression algorithms (Brotli, Deflate, GZIP, LZ4, Snappy, XZ, Zstd) and Accept-Encoding negotiation, byte for byte as PHP's extensions.

108 items17 examples8 PHP classes2.9k lines
Detectorutopia_detector
Rust

Detects a project's packager, runtime, framework and rendering from its file names, languages and manifests.

325 items10 examples43 PHP classes1.8k lines
Domainsutopia_domains
Partly Rust

Domain names split against the Public Suffix List.

28 items5 examples1 PHP classes551 lines
Emailsutopia_emails
Partly Rust

Email addresses split, checked and made canonical per provider, and their domains classified as free or disposable.

35 items1 PHP classes1.3k lines
Imageutopia_image
Partly Rust

Image previews: decode, crop by gravity or focal point, borders, rounded corners, opacity, rotation and background, then encode to JPEG, PNG, GIF, WebP or AVIF.

56 items17 examples2 PHP classes3.3k lines
Localeutopia_locale
Rust

Translations: languages, default and fallback locales, and placeholders.

26 items7 examples1 PHP classes720 lines
OpenAPIutopia-php/openapi
PHP

Framework-independent OpenAPI 2.0, 3.0, and 3.1 parser with an immutable canonical model

User agentutopia_user_agent
Partly Rust

User-agent parsing: operating system, client, device and bot.

23 items8 examples1 PHP classes2.2k lines
Validatorsutopia_validators
Rust

The checks of Utopia's request validators: booleans, integers, floats, numbers, ranges, ports, hex colors, text, identifiers, white lists, substrings, DNS labels, hostnames, domains, hosts, IP addresses, URLs, phone numbers, JSON, FCM service accounts, globstar patterns and the validators that compose others.

117 items1 examples32 PHP classes4.4k lines
Videoutopia-php/video
PHP

A simple library to probe, encode and package video for adaptive streaming

About utilities →

08Integrations#

Third-party services: AI agents, version control, orchestration, CDNs, messaging providers for email, SMS and push, and moving data between backends.

Agentsutopia-php/agents
PHP

Provider-neutral LLM toolkit for PHP: agents with tools, structured output, streaming and embeddings

CDNutopia-php/cdn
PHP

CDN cache purge and certificate provider abstractions for Utopia PHP

Messagingutopia-php/messaging
PHP

A simple, light and advanced PHP messaging library

Migrationutopia-php/migration
PHP

A simple library to migrate resources between services.

Orchestrationutopia-php/orchestration
PHP

Lite & fast micro PHP abstraction library for container orchestration

VCSutopia-php/vcs
PHP

A simple library to integrate version control systems like GitHub, GitLab etc. to receive webhook events

About integrations →