<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ffi on Luther Monson</title>
    <link>https://luth.io/tags/ffi/</link>
    <description>Recent content in Ffi on Luther Monson</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Mon, 14 Sep 2026 20:40:00 -0700</lastBuildDate>
    <atom:link href="https://luth.io/tags/ffi/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Calling Rust From PHP Without a Socket, Part 1: The Native Functions</title>
      <link>https://luth.io/blog/2026/09/calling-rust-from-php-without-a-socket-part-1/</link>
      <pubDate>Mon, 14 Sep 2026 20:40:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/09/calling-rust-from-php-without-a-socket-part-1/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; is a single Rust binary that embeds PHP. It carries its own KV store and its own&#xA;SQLite-backed database in the same process. For a long time PHP code could only reach that KV store the same way it&#xA;reaches Redis. It opened a TCP socket to the RESP listener ePHPm runs on localhost, encoded a command and waited for the&#xA;reply. That works, and every PHP Redis client in existence already speaks it. But it is a strange thing to do when the&#xA;hash map you&amp;rsquo;re talking to lives a few pointers away in the same address space.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Middleware in PHP: Compiling It With elephc, Then Not Needing To</title>
      <link>https://luth.io/blog/2026/08/php-middleware-elephc/</link>
      <pubDate>Mon, 31 Aug 2026 20:50:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/08/php-middleware-elephc/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; middleware runs &lt;em&gt;before&lt;/em&gt; PHP. It&amp;rsquo;s a small versioned C ABI, loaded with&#xA;&lt;code&gt;dlopen&lt;/code&gt;, that gets to look at a request and reject it before PHP boots or the request body is read. That&amp;rsquo;s the&#xA;right shape for a gateway. It&amp;rsquo;s the wrong shape for most PHP shops, who want to write their middleware in PHP. This is&#xA;the story of compiling PHP into a native &lt;code&gt;.so&lt;/code&gt; to fit that ABI and finding exactly where it broke. Then I built the lane&#xA;that should have existed in the first place.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why Rust for PHP Embedding (Not Go)</title>
      <link>https://luth.io/blog/2026/04/why-rust-for-php-embedding/</link>
      <pubDate>Sun, 05 Apr 2026 19:40:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/04/why-rust-for-php-embedding/</guid>
      <description>&lt;p&gt;Go is my primary language and has been for a long time. When I started building &lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt;&#xA;a few weeks ago the obvious move was to write it in Go. ePHPm is a PHP application server. It&amp;rsquo;s one binary that embeds&#xA;the real PHP interpreter (&lt;code&gt;libphp&lt;/code&gt;, the Zend engine) and puts an HTTP server, TLS, a KV cache and a database proxy&#xA;around it. A PHP app doesn&amp;rsquo;t need nginx + php-fpm + Redis to run. &lt;a href=&#34;https://frankenphp.dev/&#34;&gt;FrankenPHP&lt;/a&gt; already proved&#xA;the &amp;ldquo;PHP inside a Go web server&amp;rdquo; idea works, and it works well. I wrote it in Rust anyway. This post covers the&#xA;reasoning, and the part of the design that Rust made easier and the part it didn&amp;rsquo;t. It also has some numbers I should&#xA;have measured before I wrote the design doc instead of after.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
