Stream: ideas

Topic: WordPress Plugin Platform


view this post on Zulip Johannes Maas (Oct 21 2023 at 11:04):

I'm fascinated by Roc and thanks to roc glue, I can't shake the feeling that developing WordPress plugins might (in the long term) be possible with Roc. Is that feeling correct? Is there maybe already a place to start looking into that?

Background/motivation: I hate PHP and the WordPress APIs, but for things like association websites where I might leave, it makes sense to run it on WordPress so that others can plausibly take over.

Basically, in my head it seems possible to build a platform for WordPress plugins that gives a sane interface (which you'd have to build from the ground up). Then using roc glue, I could convert that into PHP (it's important that it is pure PHP, no C, as you would not be able to install that plugin on any server).

As a potential bonus, it might even be possible to develop pure Roc libraries that are not tied to the WordPress platform, e. g. some SQL abstraction, so that important parts could be used elsewhere. It might even be possible to build a platform that can target WordPress but also other hosting systems, who knows... (I'm getting a bit excited.)

But my main question is: Is it plausible to develop a Roc platform that spits out pure PHP WordPress plugins? (Of course, it would be a lot of work to build such a platform and the glue conversion.)

view this post on Zulip Declan Joseph Maguire (Oct 21 2023 at 11:16):

If not, it ought to be. I suspect that due to the app/platform split, Roc's killer application will be "Anything Runs Roc".

view this post on Zulip Luke Boswell (Oct 21 2023 at 12:09):

I dont know anything about PHP really, but does it have a wasm runtime? Maybe that would work nicely. Maybe there is alreay work underway for wasm plugins??

view this post on Zulip Luke Boswell (Oct 21 2023 at 12:21):

From a quick google search it looks like PHP FFI is able to load a shared library. You can make a Roc platform today and generate a library using roc build --lib myapp.roc. The you should be able to call that from PHP. Not sure about the WordPress plugin side of things.

view this post on Zulip Luke Boswell (Oct 21 2023 at 12:28):

I guess this doesn't really solve your problem as you would be leaving people with Roc code rather than PHP. But if you're interested and decide to build a prototype I can probably help you a bit.

view this post on Zulip Richard Feldman (Oct 21 2023 at 12:30):

yeah, definitely possible! The first step would be to get a bit of Roc <-> PHP interop going using PHP's C FFI. We have similar examples in the repo:

view this post on Zulip Johannes Maas (Oct 21 2023 at 14:23):

Ok, so I think I understood it wrong. :)

From https://www.youtube.com/watch?v=ZOvxa9aKCCg I somehow got the impression, that there might be a way to write glue with no intermediary C. But upon rewatching it, I realize that this does not really work in PHP, because there probably is no way to call the Roc functions directly without the FFI.

So previously I had a look at WASM (there is wasmer-php) and the PHP FFI, but I wasn't convinced that would work. But it seems that probably WASM is the most promising approach to contain the Roc functions and be called from PHP.

Thanks for the feedback! I'm absolutely fascinated by Roc and I love watching and learning from all your talks, Richard! :)

view this post on Zulip Johannes Maas (Oct 21 2023 at 14:53):

Yeah, it does not look like WASM or the FFI would be available to WordPress plugins in practice... :(

view this post on Zulip Richard Feldman (Oct 21 2023 at 15:04):

hm, why is that? I assume any PHP code is allowed to use C FFI - do WordPress plugins disable that or something? :thinking:

view this post on Zulip Brian Carroll (Oct 21 2023 at 16:26):

You say it's important for it to be pure PHP and I wonder if there's a misunderstanding.

If you are hoping to have a way to transform Roc code into PHP code then that is not how things work with Roc.

We compile Roc to machine code or Wasm. We don't have a way to compile it to other languages.

But we normally need interface to that machine code using a very thin wrapper in the host language.

So we have Roc glue to do that.

But it can only generate this thin wrapper. It is definitely not the same as compiling Roc to other languages.

view this post on Zulip Brian Carroll (Oct 21 2023 at 16:27):

Oh actually rereading your later comment I think you'd figured that out.

view this post on Zulip Johannes Maas (Oct 22 2023 at 07:14):

Yes, that's pretty much exactly what happened! :) Thanks for the summary, though, helpful to have it laid out like that.

view this post on Zulip Johannes Maas (Oct 22 2023 at 07:16):

I couldn't find a way to check whether FFI is usually available, especially in the context of plugins. So I assume it is not, but I haven't really tested it e. g. on the server we rent.

Basically, all this guesswork is exactly why I find PHP so frustrating.

view this post on Zulip Johannes Maas (Oct 22 2023 at 07:28):

Yeah, looking into again, it seems that for both FFI and WASM you'd need to have a PHP extension active, which I fear I cannot guarantee on all servers.


Last updated: Jun 16 2026 at 16:19 UTC