Sulat.com / Writing on AISaturday, December 5, 2026
Enter →
Agent Engineering/5 December 2026

Sending Laravel PHP jobs to Rust and Go workers

Sander Muller’s bridge lets a Laravel PHP app send one heavy job to a Rust or Go worker. I had Codex wire it up and ran 2 million rows through Rust, Go and PHP.

Red glass 3D Laravel logo sending a glowing job block along two rails to an orange gear mechanism, with a return loop back.
Illustration: Sulat, featuring the Laravel logo

At a glance

  • Sander Muller’s laravel-rust-bridge and laravel-go-bridge let a Laravel PHP app send one heavy job to a Laravel Rust or Go worker and get the result back as an event.
  • I had Codex wire up the PHP side, the Rust job, the Go job and a plain PHP baseline, one prompt each, and the three jobs wrote byte-identical files.
  • On a 2-million-row CSV summary the Rust worker took a median 0.77 seconds, Go 1.35 and the PHP queue job 7.96.
  • The bridge README says it reads laravel-rust 0.1.x, and it worked on 0.2.0 for both Rust and Go.
  • Five deliberate mistakes all failed with errors, and delays, chains and batches aren’t supported yet.

Sander Muller’s laravel-rust-bridge lets a Laravel PHP app hand one heavy job to a Laravel Rust worker and get the result back as an event. A sibling package, laravel-go-bridge, does the same for Laravel Go. I had Codex wire up both, then ran a 2-million-row CSV summary through a Rust worker, a Go worker and a plain PHP queue job on the same machine. Rust took about 0.8 seconds, Go about 1.4 and PHP about 8, and all three wrote byte-identical files.

I covered the runtimes themselves in my Laravel Rust guide and Laravel Go guide. This one is about the way in for an app that already exists.

The idea

Most teams with a Laravel app can’t rewrite it in Rust or Go. They can move one expensive job: a big export, a CSV import with hundreds of thousands of rows. That’s the case Sander makes in his GitHub issue on the Laravel Rust repository, and the bridge is his working example. PHP stays the app and acts as the dispatcher. A Rust or Go worker runs beside it as a sidecar, takes the one job type you move and tells PHP when it’s done.

Comparison: rewriting a whole PHP app in Rust, crossed out, versus keeping PHP and sending one heavy job to a Rust worker.
Move the heavy job, keep the rest of the app in PHP.

It works because the bridge writes the job in Laravel Rust’s own JSON payload instead of a PHP serialised object, then pushes it to Redis (or SQS), where the Rust worker reads it. A normal PHP job holds a serialize() object that a Rust worker can’t read. Because the receiver is a real Laravel Rust queue worker, the job keeps retries and failed-job handling. The bridge README says a hand-rolled worker that pops a Redis list loses a job when it crashes mid-run, has no retries or failed jobs and reads one job type per queue.

The way back is the careful part. The Rust job inserts a small JSON message into a database table. A queue driver in the bridge, rust-callbacks, rewrites every message into one fixed job that holds only a name and a data array before Laravel reads it. A message can’t name another class and nothing in it is unserialised, so a buggy or compromised Rust app can’t run code in PHP. PHP then fires a RustCallbackReceived event and your listener acts on it.

Five boxes: PHP sends the job, Redis holds it, Rust runs it, Rust reports back in a table, PHP hears about it as an event.
A job goes out through Redis and comes back through a database table.

The issue lists four things that block this today, and the bridge works around each:

  1. The payload format is internal to the framework, so PHP can write it only by copying an internal struct.
  2. Laravel PHP prefixes Redis keys and Laravel Rust reads unprefixed ones, so PHP needs a separate connection with no prefix.
  3. The database queue tables differ. Laravel Rust’s jobs table uses timestamp columns and Laravel PHP’s uses Unix-second integers.
  4. There’s no supported way back from Rust to PHP, which is why the bridge adds the callback driver.

What I built

I built one Laravel 13 PHP app, one Laravel Rust app and one Laravel Go app on one machine, and one job. The job, orders.summarise, reads a 2-million-row orders CSV of 95.6 MB with the columns id, customer_id, country, category, amount_cents and created_at. It counts valid and bad rows, totals orders, revenue and the mean per country, finds the 95th percentile order amount and the top five customers, writes a JSON file and tells PHP it’s done. 3,124 rows are bad, with an empty country or an amount that isn’t a non-negative whole number of cents, so 1,996,876 are valid.

Codex wrote all the application code. I ran Codex CLI on my ChatGPT subscription, with its connected apps switched off, one prompt per step and each step in its own session. The model was GPT-6.2-Sol. The versions were Laravel 13.45.0 on PHP 8.4, laravel-rust-bridge 0.2.0, laravel-go-bridge 0.2.0, laravel-rust 0.2.0 and go.laravel.com 0.2.0.

The bridge README says it reads laravel-rust 0.1.x and tells you to pin the crate to an exact version. Both frameworks were already on 0.2.0 when I ran it, and the bridge worked on both, with the payload still at version 1.

Step one: the PHP side

The first prompt installs the bridge and wires the app. This is the prompt, word for word.

Code
Install sandermuller/laravel-rust-bridge in this Laravel app and set it up for the Redis transport: predis, an unprefixed `rust` Redis connection on database 5, and the `rust` queue. Add the rust-callbacks queue connection on the database and migrate. Then add an artisan command `orders:dispatch {report}` that creates a pending row in a new `reports` table (id, status, rows, bad_rows, finished_at) and dispatches the Rust job `orders.summarise` with the report id and the path /work/data/orders.csv. Add a listener so the `orders.summarised` callback, which carries report_id, rows and bad_rows, marks that report done. Run php artisan to check the command is registered. Don't start any workers.

Codex finished in 1 minute 20 seconds. It installed the package and Predis, added the unprefixed rust Redis connection on database 5 and the rust-callbacks queue connection on the database, created the reports and rust_callbacks tables, and wrote a command and a listener. The command refuses a report id that already exists, then dispatches the job by its name.

Code
$jobId = $bridge->dispatch('orders.summarise', [
    'report_id' => $reportId,
    'path' => '/work/data/orders.csv',
]);

The listener checks the callback’s types before it marks the report done, which is the README’s advice to treat callback data as input.

Code
if (! is_int($reportId) || $reportId < 1 || ! is_int($rows) || $rows < 0 || ! is_int($badRows) || $badRows < 0) {
    throw new InvalidArgumentException('Invalid orders.summarised callback data.');
}

DB::table('reports')
    ->where('id', $reportId)
    ->where('status', 'pending')
    ->update([
        'status' => 'done',
        'rows' => $rows,
        'bad_rows' => $badRows,
        'finished_at' => now(),
    ]);
The whole PHP step, from prompt to summary. Nothing was edited or sped up.
Codex CLI summary after installing the Rust bridge in the PHP app: the dispatch command, the listener and the migrations.
Codex wired the PHP side in 1 minute 20 seconds.

Step two: the Rust job

The second prompt goes in the Rust app. It names the job and its fields, so Codex had the contract it needed, and it points Codex at the bridge README rather than explaining the bridge.

Code
This is a Laravel for Rust app. A Laravel PHP app in /work/php-app dispatches the job `orders.summarise` to it through laravel-rust-bridge (read vendor/sandermuller/laravel-rust-bridge/README.md there). Add that job with a stable name and the fields report_id and path. It streams the CSV at path (columns id, customer_id, country, category, amount_cents, created_at) and writes /work/out/rust-{report_id}.json with: rows (valid rows), bad_rows (empty country, or an amount_cents that is not a non-negative integer), countries (keyed by country code, each with orders, revenue_cents and mean_cents as integer division), p95_cents (nearest rank over the valid amounts), and top_customers (five customer_id and revenue_cents pairs, highest revenue first, ties by lowest customer_id). Then send the orders.summarised callback with report_id, rows and bad_rows into the PHP app's rust_callbacks table, which lives in the postgres database php_app on the same server (user postgres, password secret). Check it builds with cargo build --release. Don't start any workers.

Codex took 5 minutes 53 seconds and the app built first time. It added the job, two crates (csv and tempfile) and a second database connection named php that points at the PHP app’s Postgres database, so the job can write its callback row. The job’s shape is the whole contract with PHP. The field names are the keys PHP sends, and the name in #[job(name = ...)] is the string PHP dispatches.

Code
#[derive(Queueable)]
pub struct SummariseOrders {
    pub report_id: i64,
    pub path: String,
}

#[job(name = "orders.summarise")]
impl SummariseOrders {
    pub async fn handle(self) -> laravel::Result<()> {
        let Self { report_id, path } = self;
        let (rows, bad_rows) = task::spawn_blocking(move || {
            write_summary(report_id, &path)
                .map_err(|err| Error::msg(format!("could not write orders report {report_id}: {err}")))
        })
        .await??;

The callback is the JSON from the README, inserted into the table the PHP queue driver reads. The timestamps are Unix seconds, because that’s what Laravel PHP stores.

Code
let php = db::connection("php")?;
let payload = serde_json::json!({
    "data": {
        "name": "orders.summarised",
        "data": { "report_id": report_id, "rows": rows, "bad_rows": bad_rows },
    },
    "maxTries": 3,
})
.to_string();
let now = laravel::now().timestamp().as_second();

db::query!(
    php,
    "INSERT INTO rust_callbacks (queue, payload, attempts, reserved_at, available_at, created_at)
     VALUES ('default', {payload}, 0, NULL, {now}, {now})"
)
.insert()
.await?;

Codex also worked out the 95th percentile without floating point, by counting amounts in a sorted map and walking to rank rows - rows / 20. Running the three commands that make one round trip, with the Rust worker set to exit after one job, looks like this:

Code
php artisan orders:dispatch 42
./target/release/laravel-rust-skeleton queue:work redis --queue rust --max-jobs 1
php artisan queue:work rust-callbacks --once

The report row went from pending to done with 1,996,876 rows and 3,124 bad rows, and the JSON file was on disk.

Codex writing the Rust job from one prompt. Nothing was edited or sped up.
Codex CLI summary of the Rust orders.summarise job: it streams the CSV, writes a JSON file and inserts the callback row.
Codex built the Rust job in 5 minutes 53 seconds and it compiled first time.

The same job in PHP and Go

A speed number needs a fair PHP version of the same job, so the third prompt asks Codex for one.

Code
For a fair comparison, add a plain PHP queued job SummariseOrdersInPhp that does the same work as the Rust orders.summarise job, in PHP. It streams the CSV at /work/data/orders.csv (columns id, customer_id, country, category, amount_cents, created_at) and writes /work/out/php-{report_id}.json with: rows (valid rows), bad_rows (empty country, or an amount_cents that is not a non-negative integer), countries (keyed by country code, each with orders, revenue_cents and mean_cents as integer division), p95_cents (nearest rank over the valid amounts), and top_customers (five customer_id and revenue_cents pairs, highest revenue first, ties by lowest customer_id). Then it marks the report done with its rows and bad_rows. Add an artisan command orders:dispatch-php {report} that creates the pending report and dispatches the job on the redis queue connection, queue php. Write idiomatic, reasonably fast PHP and keep memory flat. Check the output against /work/out/rust-1.json with a quick script, but don't start any workers.

Codex took 1 minute 28 seconds. It streamed the file with fgetcsv, checked amounts with ctype_digit, kept the percentile in a histogram and wrote the file atomically. Its output matched the Rust file byte for byte.

Codex CLI summary of the plain PHP queue job that does the same work, checked against the Rust output.
The PHP baseline Codex wrote matched the Rust output byte for byte.

The Go bridge has the same API with its own names. The fourth prompt adds it to the PHP app and builds the job in a Laravel Go app.

Code
This is a Laravel for Go app. A Laravel PHP app in /work/php-app already dispatches the job `orders.summarise` to a Laravel Rust worker. Do the same for Go: add laravel-go-bridge to /work/php-app (read its README after installing), with an unprefixed `go` Redis connection on database 6, the `go` queue, the go-callbacks queue connection on the database, and an artisan command `orders:dispatch-go {report}` that creates the pending report and dispatches `orders.summarise` with report_id and path /work/data/orders.csv. Make the orders.summarised callback mark the report done, the way the Rust one does. In this Go app, add the job with a stable name. It streams the CSV and writes /work/out/go-{report_id}.json with the same fields as /work/out/rust-1.json (rows, bad_rows, countries, p95_cents, top_customers) so the two files match byte for byte, then sends the orders.summarised callback into the PHP app's go_callbacks table in the postgres database php_app (user postgres, password secret). The Go app's .env is set up. Check that it builds, and don't start any workers.

Codex took 2 minutes 58 seconds. The Go job is the same idea with different idioms: a struct with JSON tags, a JobName() method for the stable name and a Handle(ctx) method for the work.

Code
type SummariseOrders struct {
	ReportID int64  `json:"report_id"`
	Path     string `json:"path"`
}

func (SummariseOrders) JobName() string { return "orders.summarise" }

Codex checked the Go output against the Rust file and built the app, and it left the workers for me. I ran the Go worker, and PHP marked the report done through the go-callbacks driver. The Go file matched the Rust file byte for byte.

Codex CLI summary of the Go orders.summarise job and the Go bridge wiring in the PHP app, with build and tests passing.
The Go job came out of one prompt too, and matched the Rust file byte for byte.

How fast it was

I ran each job five times on the same file. Every run starts a fresh process, with --max-jobs 1 for Rust and Go and queue:work --once for PHP, so process start-up is inside every number. The CSV was already in the page cache. The table shows the worker’s wall-clock time and its peak memory.

WorkerMedianRangePeak memory
Laravel Rust0.77 s0.66 to 0.81 s54 to 58 MB
Laravel Go1.35 s1.22 to 1.45 s69 to 70 MB
Laravel PHP queue job7.96 s7.63 to 8.35 s68 to 69 MB
Two million rows, five runs each. Rust was about 10 times faster than PHP and Go about 6 times.
Snail for a PHP worker at about 8 seconds, rocket for a Rust worker at about 0.8 seconds, on the same two million row file.
The same file gave the same answer in about 8 seconds on PHP and 0.8 on Rust.

This is one job on one file. It reads and aggregates a CSV, which is the kind of CPU-bound work the pattern is for. PHP ran as the command-line runtime with no opcache or JIT, and a long-lived PHP worker would skip the framework boot on every job after the first. Rust and Go wouldn’t get that saving. Peak memory stayed at or under 70 MB in all three because each job streams the file, so the gain from the sidecar is time, not memory.

Five mistakes I tried

Each of these failed loudly, and none was silent:

Checklist of five bridge mistakes, each with the error it produced: prefixed Redis, wrong field type, unknown job, class name, bad callback.
Each of the five mistakes I tried failed with an error, none silently.
  • A prefixed Redis connection made PHP throw MisconfiguredBridge before it dispatched anything. I switched the prefix on to see it and switched it back.
  • A field of the wrong type made the Rust worker fail the job and name the field.
  • A job name Rust didn’t know made the worker fail the job and name it.
  • A callback that carried a class name was ignored. The driver reads the name and data fields only, and nothing is unserialised.
  • A callback with an invalid name failed on its first try and landed in PHP’s failed jobs.

The last one matters in practice. A bad callback shows up in failed_jobs, where you can see it and retry it.

Where it fits

The pattern suits work that’s heavy, self-contained and given by id: a statistics export, a large import, a report that streams a file. It doesn’t suit a job that needs your PHP code. A Rust or Go job can’t call your Eloquent models or send a Laravel mail, and the README lists delays, chains and batches as not supported yet. If PHP has to know the result, it comes back as a callback with ids and counts, not as an object.

OptionWhat you getWhat it costs
Keep the job in PHPNo new runtime. My PHP job took about 8 seconds on one core and peaked at 69 MB.Speed, unless you add workers or tune the job.
The bridgeOne job on Rust or Go, with retries, failed jobs and a safe callback. The rest of the app stays in PHP.A second app to build and deploy, a beta payload format and the Redis and table setup above.
Your own worker with pushRaw()Plain JSON to a worker you write.According to the README, a job lost on a crash, no retries or failed jobs and one job type per queue.
Rewrite on Laravel Rust or GoThe whole app in the new runtime. Cognition is offering Devin credits for these migrations.The rewrite, which is the thing most teams can’t do.
The bridge sits between doing nothing and a rewrite.

The same move, keeping the main stack and sending the hot path to Go, shows up elsewhere. Next.js 16.5 has experimental route.go files that run Go beside TypeScript, in my Next.js Go routes guide, and Spatie ported 44 PHP packages to Go, in my look at Spatie’s Go packages. If you deploy on Laravel Cloud, it now runs Go and Rust apps, though I didn’t deploy this setup there.

Pitfalls

  • Pin both sides. The payload is internal to the framework, and the README says to pin the Rust crate to an exact version and upgrade both sides together. If the format changes, the worker fails the job and says so instead of misreading it.
  • You need PHP 8.4 and Laravel 12 or 13.
  • The Redis connection for the bridge must have no prefix. Set options.prefix on that connection and leave the global prefix alone.
  • Give the Rust or Go worker its own queue name. On SQS the bridge throws if a job would go to the connection’s default queue, which PHP workers read. I tested Redis and the database callbacks and didn’t test SQS.
  • Set a stable job name on the Rust or Go side. Without one, the Rust name is the module path, and renaming the module breaks every job PHP sends.
  • Send ids, not secrets, and authorise in PHP before you dispatch. The payloads sit unencrypted in Redis, and a failed callback’s data stays in failed_jobs.
  • Run a worker for the callback connection next to your other workers: php artisan queue:work rust-callbacks.

Where it’s going

Sander’s issue asks the Laravel Rust team four questions: whether they want to support dispatching from PHP, whether the payload can become a documented and versioned contract, where the PHP side should live (in laravel/framework, a first-party package or the community) and whether the framework should ship a Rust helper for sending a callback. The issue sits in the backlog with no assignee. Today the Rust app writes the callback row by hand, as in the code above, and a documented payload is the piece that would make the bridge safe to depend on without pinning.

Everything ran on one 4 vCPU Intel Xeon 2.10 GHz virtual machine with 15 GB of memory and a 252 GB disk, under Ubuntu 24.04 with Linux 6.18. It ran PHP 8.4.28, Rust 1.100.1, Go 1.27.4, Redis 7.0.15, PostgreSQL 16.15, the workers and the load together, with Codex CLI 0.174.0 on the same box.


Sources

Disclosure: I’m an OpenAI, Firecrawl and Devin ambassador. Codex wrote the app code, and I link to Devin’s migration credits.