<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Composer on MongrelDB</title><link>https://www.mongreldb.com/articles/tags/composer/</link><description>Recent content in Composer on MongrelDB</description><image><title>MongrelDB</title><url>https://www.mongreldb.com/logo.png</url><link>https://www.mongreldb.com/logo.png</link></image><generator>Hugo</generator><language>en-US</language><lastBuildDate>Fri, 10 Jul 2026 09:00:00 -0500</lastBuildDate><atom:link href="https://www.mongreldb.com/articles/tags/composer/index.xml" rel="self" type="application/rss+xml"/><item><title>Pure PHP in 2026: A Database Client That Ships With Composer</title><link>https://www.mongreldb.com/articles/2026/07/pure-php-in-2026-a-database-client-that-ships-with-composer/</link><pubDate>Fri, 10 Jul 2026 09:00:00 -0500</pubDate><guid>https://www.mongreldb.com/articles/2026/07/pure-php-in-2026-a-database-client-that-ships-with-composer/</guid><description>The mongreldb-php client installs with composer require, needs no phpize, no PECL, and no native ABI matching, because pure PHP is still a feature in 2026.</description><content:encoded><![CDATA[<p>PHP runs everywhere, and everywhere has a different OS version, a different architecture, and a hosting provider whose control panel says &ldquo;Native extensions: contact support.&rdquo; That sentence is not hypothetical; it describes the deployment environment for a substantial fraction of PHP applications in production today, and if your database client requires a compile step or a PECL install, you either open a support ticket or you pick a different database. MongrelDB&rsquo;s PHP client ships as pure PHP, installs with <code>composer require visorcraft/mongreldb-php</code>, and speaks to a <code>mongreldb-server</code> daemon over plain HTTP, which means the only thing it requires of the host is a working PHP 8.4+ runtime and a network path to the server.</p>
<h2 id="what-pure-php-actually-means-in-2026">What pure PHP actually means in 2026</h2>
<p>The phrase &ldquo;pure PHP&rdquo; has accumulated some baggage over the years, partly because PHP&rsquo;s early reputation as a slow interpreted language made &ldquo;pure PHP&rdquo; sound like &ldquo;slow PHP,&rdquo; and partly because the PHP ecosystem spent a decade leaning on C extensions as proof of seriousness. Neither of those associations is accurate anymore, and the PHP client does not trade on either of them.</p>
<p>What pure PHP means here is concrete: the entire client is written in PHP 8.4 syntax, it ships as a Composer package, it has no native code dependencies, and it does not call any function that requires a C extension. HTTP is handled by <code>curl</code> via ext-curl when PHP 8.5 persistent handle sharing is available (PHP 8.5 being the newer of the two runtimes, so the stream-context path remains the common case for now), and by regular stream contexts when it is not; both are in the standard PHP distribution and neither requires a compile step. JSON is handled by <code>json_decode</code> and <code>json_encode</code>, which have been built into PHP since 5.2 and have been reliably fast since 7.0. There is no binary .so to load, no phpize to run, no ABI version to match against the server&rsquo;s architecture, and no risk that <code>pecl install mongrel</code> fails because your host has disabled exec() in php.ini.</p>
<h2 id="the-install-experience">The install experience</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-php" data-lang="php"><span style="display:flex;"><span><span style="color:#a6e22e">composer</span> <span style="color:#66d9ef">require</span> <span style="color:#a6e22e">visorcraft</span><span style="color:#f92672">/</span><span style="color:#a6e22e">mongreldb</span><span style="color:#f92672">-</span><span style="color:#a6e22e">php</span>
</span></span></code></pre></div><p>That is the entire install. The package lands in <code>vendor/</code>, autoloading is configured, and you can instantiate the client in one line:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-php" data-lang="php"><span style="display:flex;"><span><span style="color:#66d9ef">use</span> <span style="color:#a6e22e">Visorcraft\MongrelDB\Client</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>$db <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Client</span>(<span style="color:#e6db74">&#39;https://db.example.com&#39;</span>, <span style="color:#a6e22e">token</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">getenv</span>(<span style="color:#e6db74">&#39;MONGRELDB_TOKEN&#39;</span>));
</span></span></code></pre></div><p>No bootstrap scripts, no extension loading in php.ini, no running <code>mongreldb-php-setup</code> as a post-install script. The Composer package ships the client, the type stubs, and the error hierarchy; you require the package and you are talking to the database.</p>
<h2 id="why-http-is-the-right-transport-for-a-pure-php-client">Why HTTP is the right transport for a pure PHP client</h2>
<p>The PHP client could have used a Unix socket or a raw TCP protocol with a binary framing layer, and in a pure-server context those choices would make sense for latency. But PHP is not a long-running process by default; PHP-FPM spawns a process per request or per few requests, and the typical PHP application opens a fresh database connection on every web request, closes it at the end, and does not reuse it unless you have gone out of your way to implement connection pooling. An HTTP client reuses keep-alive connections across requests in the same process lifetime, and when PHP-FPM recycles a worker the next request starts fresh, which is the same behavior the database would have expected anyway.</p>
<p>HTTP also means the PHP client works through every HTTP-aware proxy, load balancer, and API gateway that already exists in your infrastructure, and it means TLS termination happens at the normal layer rather than requiring a special database-facing certificate setup. You are already doing HTTP for every other external service your application calls; the database does not need to be special.</p>
<h2 id="what-you-give-up-and-what-you-do-not">What you give up and what you do not</h2>
<p>You give up the single-digit-microsecond in-process path, because HTTP adds a header processing layer that a raw TCP protocol would not have (a few hundred microseconds of framing overhead per operation, not a category shift), and you give up the ability to operate without a network path to the server, which is the embedded-database use case that MongrelDB handles differently through its Kit SDK. For a PHP web application that talks to a <code>mongreldb-server</code> over a LAN or a VPC, those tradeoffs are not on the critical path; the query execution time inside the database dominates the HTTP overhead by two orders of magnitude.</p>
<p>You do not give up type safety, because the client speaks a typed wire format and deserializes responses into PHP native types with a full exception hierarchy that maps HTTP status codes to domain exceptions, so a <code>404</code> from the server becomes a <code>NotFoundException</code> in your application code rather than a generic runtime error. You do not give up connection pooling in the PHP-FPM context, because the client uses persistent curl handles when PHP 8.5 is available, which means the underlying TCP connection is reused across requests in the same worker process without the TLS handshake cost on every page load. And you do not give up SQL surface area, because the wire format carries the same query plans and constraint semantics as the Kit SDK and the Rust core, so the PHP client is not a reduced-surface wrapper; it is the full client in a different transport.</p>
<h2 id="who-benefits-from-this-in-practice">Who benefits from this in practice</h2>
<p>The obvious answer is the shared-hosting developer who is on a cPanel machine with no root access and no ability to run phpize, and that answer is correct but incomplete. The more interesting case is the CI pipeline: a <code>composer require</code> in a Dockerfile that uses <code>php:cli</code> as its base image does not need any system package installed beyond the PHP runtime and Composer itself, which means your test matrix can cover PHP 8.4 and PHP 8.5 on the same Docker image without an extension compilation step slowing down every build. The pure PHP client makes your database client a first-class Composer dependency rather than a system-level install, and that distinction matters when your CI minutes are metered and your container build time is on the critical path.</p>
]]></content:encoded></item></channel></rss>