An alternative PHP server built in Rust

Hello everyone! As many people in this forum, I'm coming from the PHP world, and I wanted a real use-case to learn Rust, so I came up with this experiment: https://github.com/Pierstoval/rymfony

TL;DR: it's an open-source alternative to the Symfony CLI binary, which is built in Go and is closed-source.

The goal is this:

  • Run an instance of php-fpm (linux) or php-cgi (windows) in the background, as a child process.
  • Run an HTTP server
    • On each request, the server built with Rust must use the FastCGI protocol to proxy the request to the PHP process.
    • Then, it must retrieve the response from PHP and return it to the client.

There are tons of other goals, but the first and most important one is this server.

For now, I succeeded in finding a suitable PHP executor (fpm or cgi), and run it in the background. I can even run the native PHP server (through a php -S 127.0.0.1:9000-like command).

I'm still learning Rust, and the implementation of this specific feature is a real struggle for me, because I'm not going easy and I start with the most complex stuff (borrows, lifetimes, all things I still can't understand despite having read the associated sections in the Rust book).

You can see it all in the related PR. I started with using Hyper, tried Sozu and Surf to create a proxy, and realized I actually needed to use the FastCGI protocol (better late than never :sweat_smile: ).

Every time I compile the binary, I have a cryptic error (borrows, moves, lifetimes, concrete types, I think I've seen them all :rofl: ).

This time, I'm really asking for help, because it starts getting on my nerves, and I really want this project to succeed at least in its most basic and necessary feature.

With the Symfony CLI we can do symfony serve -d and voilà! We have a running HTTP/2 server with native TLS that proxies to an automatically detected PHP setup (fpm on linux and cgi on windows).

I want the same, but in Rust, and open-source, and I think that if the base features are usable, the community will be really interested in this tool :slight_smile:

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.