Use Elixir to create the next Wordpress?

  • Is it a bad idea?
  • Is Elixir the correct tooling?
  • Technical constraints?
  • How to handle the plugins, themes ecosystem? (maybe mix install?)

Thank you for reading :smiley:

2 Likes

Such a platform requires pluggable add-ons. Elixir can achieve that but it’s not trivial, and security can definitely be an issue.

5 Likes

This is not unique to elixir though. Any platform without sandboxing has that problem, including PHP/Wordpress itself.

3 Likes

Yep, true. In fact I don’t know of a language/platform that does this well. I still remember people breaking Java’s security subsystem years ago, maybe that was improved in the meantime.

I think, this is the greatest problem.
This is also true if you wanted to program an extensible Ecommerce system, for example. There are some comments about this here in the forum.

2 Likes

Yes. Unless we get a hard sandbox for the BEAM VM then I don’t think such efforts will ever go anywhere.

Of course there are other options like just use a Lua engine to program plugins but then the single language paradigm of such platforms goes down the drain and you might as well not use a BEAM language at all.

I am sure there are ways around it but it’s probably too hard to be worth it.

1 Like

Or accept the security implications like many other systems, which provide runtime supplied pluggable functionality.

1 Like

Yes. I still wouldn’t mind (if it was my job) because Elixir still has a ton of advantages compared to JS or PHP for such projects. But it needs to be said that it’s not at all easy to pull off.

1 Like

I’ve thought about this a lot, and have come to the conclusion that plugins basically destroy the premise of doing this in most languages (not an Elixir thing). It feels like PHP is actually uniquely positioned as the best foundation for a WP-like system.

You could totally build a drop-in plugin system in Elixir, although it would be much more involved because you’d need to compile the plugins and add the compiled source to the application. The code_server process can handle this dynamically, I believe. Then questions like, what would prevent a plugin from overwriting an existing module? The security can of worms is big on this project.

The even harder thing about plugins is that they can completely change the operation of core wordpress operations. So having a pure core separate from the plugins isn’t really applicable in practice. I don’t think you could simply ignore it because the UX depends on having a powerful plugin system that can change the operation of the system. Modifications to wp-theme.php are the bane of any WP developer, but is also quite common because software is hard.

4 Likes

I’m curious why you think PHP is uniquely positioned for such a system? By my understanding PHP has exactly the same issues. Sure there’s compilation, but the beam and elixir have quite nice api around doing that even at runtime. The statefulness of the system means you need to be a bit more diligent with unloading stuff compared to the ā€œload everything from scratch each requestā€ in PHP, but other than that I don’t really see a big difference.

1 Like

My main reason for this is that everything in PHP is drop-in and evaluated on every request. So you literally just need to put files there and it works. The devil is in the details—it just works in PHP but you’d need to replicate it to have the same effect, and I’m not sure it’s super easy to do. The other thing about it is that PHP files are edited live in pretty much any major WP installation. It’s just a feeling though, I don’t have a ton of empirical evidence here because I haven’t seen it attempted in earnest.

I suppose you could build that type of system in other languages (dealing with compilation as needed, setup files correctly, etc), but I’m not aware of other systems that have replicated this.

In PHP the new code will be loaded in an isolated process instead of being system wide, and you will not be able to redefine a module/class that already exists. This is best to try to run malicious code.

Plus PHP is easier with ā€œone click installā€ providers I guess. That being said, I find using Luerl for plugins could be very cool and safe, though maybe not very fast.

Thank you for all your responses, it boosted my confidence.

I thought I will list some of the top Wordpress plugins & find-out how to implement it, likely the most of them should be implemented in core, including:

  • Content management: should be like (Drupal, or Strapi) content types; User can define Post, Service, Project, …, & attach field to them
  • Querying, filter data: Ecto Query is a beast
  • The admin dashboard: not many people will use the admin dashboard, so we will keep all the state (Ecto data) in the LiveView socket, so mutations will be very fast; this is a big win
  • Field types: user also can define any field type, this will be validated with json schema (can replace Wordpress ACF Advanced custom field)
  • Products/orders: should be like Spree / Solidus
  • Rich text editor: Slate.js is a wonderful tooling for this (Slate can be serialize into json object), I think it should be handle on client side to reduce comunication between client-server (we later can use LiveView to render rich text object created by Slate)
  • Page builder: A block builder, just a set of some prebuilt component that can be composed
  • Dynamic routes: can be easily customized with Phoenix
  • SEO stuff: should be in core (like Yoast SEO)
  • SEO audit: should be in a separate app in umbrella; can analyze the content using internal (database) or external (send request) query
  • The system will expose an GraphQL endpoint using Absinthe
  • Image compression
    • When user upload an image, we will execute a sharp cli (will be bundled by the app) to generate derived images (argument should be like w_1200, w_1200,h_800 ), if it slow, we can make them communicate via RabbitMQ
  • Theming?
    • In some of my previous project, they were built with Svelte, React, Vue that consume data from GraphQL endpoint and bundled to ESM project, or docker image; managed by version. I see it’s too complicated.
    • Allow user to edit css directly, like some Tailwind editor out there, can be compiled & generate to minimized css
    • LiveView & Surface is evolving, so I thought we can build components using Surface. My try will be create an app for each theme, and call mix install (same for other plugins that haven’t listed above), do we have something like mix uninstall to unload an app?
  • Data Migration

Am I missing something important here? :smiley:
Thank you for reading; :smiley:

4 Likes

I’ve spent some time thinking about this and some time going down paths I abandoned.

I have an effort underway which I’ve shared some stuff about in my newsletter. Since I’m aware that a CMS is a massive effort I’m trying to start with foundational libraries and stacking those bricks up over time.

Even on just this forum I’ve seen this idea come up and fall down.

I think Elixir could do great at CMS things but the road to featureful enough is absurd.

Give it a shot if you like. I applaud any effort in that direction but be aware that it is a lot of work.

My view on ā€œsolvingā€ the CMS problem is pretty particular and it involves tackling this particular painpoint, among others: Underjord | The WordPress merging problem

For me it begins with making content type creation strong. And going down that route you’ll find out that Ecto schemas really are very compile-time and if you don’t want arbitrary atom proliferation, from code-gen, as a risk that leads to other choices. Can of worms :slight_smile:

I can share more when and if it starts to make sense :slight_smile:

12 Likes

There is a CMS system in itself for many years: Zotonic

However, Zotonic is based on Erlang, which can be extended and customized with your own modules and templates. The template-system is based on erlydtl.

My interest is rather Ecommerce, also for this Elixir would be actually well suited, there are also some companies that use it exactly for this, but just proprietary:

https://www.stitched.co.uk
https://www.therealreal.com/

For an open source ecommerce system you would need the possibility to develop plugins, especially to program your own themes for the store.

In Zotonic, for example, you can extend the template’s in a simple way via the blocks as in Django or PHP-Twig.

Zotonic Template’s

Twig-Template’s for Shopware

From time to time I try to figure out how to do this in Phoenix, but unfortunately I haven’t made any progress. Especially if there are other solutions instead of blocks? In such a store system, however, there can be hundreds of blocks, which are very fine-granular (as you can see in the shopware example).

I would be grateful for ideas regarding extensible templates in a nice way.

6 Likes

OMG I would so help you do this!! But I have to come back when I’m more awake. I’m going on awake idk, something crazy like 24+ hrs now. Yea so, goin to bed soon. But I love this thread. I’ll be back!! WOOT WOOT I’m already excited to do this!!!

I agree. The 3 complicated issues in building a decent CMS are:

  • Customizable content data schema without slowing down the whole system. Meaning on the fly migrations, etc…
  • Not saving configuration in database. Only data. Everything config related should be version controlled. Then the question is how to manage keys in a secure way ?
  • Finally, the plugin issue. Only solution I found is plugins should be separately deployed apps in the same cluster, subscribing and replying to events.
1 Like

When you say, Wordpress, what do you mean, a content management system with WYSIWYG editing, image storage, and installable themes?

I would say those 3 are features that are not core to a CMS. Some CMS are headless, hence don’t need themes. If by WYSIWYG you mean drag and drop page builder, there were CMS before this exists. Images is just a type of content usually called Assets. Most CMS include a Digital Asset Management module, but, again, it’s an added feature.

I would venture the minimum set of features of a CMS would be:

  • creation and editing of content
  • a way to organize of content ( categories, tags, content types )
  • user management
  • content publishing ( publish, unpublish )
  • content storage ( db )

then, there need to be a way to distribute that content, depending on the platform. On the web, it would be linking a URL to a piece of content.

3 Likes

I’m intrigued by the title of the post since it’s something I’ve been thinking about a lot, I see the following problem, coming from the place of wanting to sometimes build websites for individuals and small to medium scale institutions:

Wordpress and similar PHP-backed headful (also rendering the website) CMS systems still offer an unmatched workflow for some reason:

  • You define a content schema in the UI
  • You write a theme in PHP
  • You’ll deploy everything including a database on one of the millions of PHP/wordpress specific hosts that exist for every country, with ease
  • You hand the hosting over to a client and they can edit the content in the CMS admin panel and update the website any time with ease, everything is pretty much seamless

Now web development has progressed over time, and there are much better options for building content-driven websites, I really like static site generators, Astro is a great one for example, I think the developer experience is kind of unmatched and on a technical level, generating HTML ahead of time and then just serving it makes a lot of sense compared to rendering every page on demand and hitting a database on every request when the content really only changes like once a month.

The problem is there is no CMS with a workflow as straightforward as what I mentioned above.
If it’s your own website, editing markdown files by hand may be an option, but you can’t expect non-technical users to be doing that, it barely works even with a wysiwyg editor.

There is the option of using a headless CMS, the cloud / Saas ones are usually quite expensive (see: Contentful), self hosting an Open Source one (Payload, Strapi, Directus) is feasible but comes with a maintenance burden – then you also need to rebuild the page on every change so you’d have to set that up usually on a secondary service that does the building and hosting like Cloudflare Pages or Netlify, which also means you probably also want to have a hosted git repo connected to that, from a third service like GitHub or GitLab, it just explodes in complexity, and how do I hand some amalgamation of services like that over to a client?

The git-backed static CMS (Like Netlify CMS, now Decap) options are okay, until you are dealing with sites that are heavy in media, then storing everything in a git repo is not feasible anymore and you have to add on services like a git LFS provider or S3, and you always need a minimal backend for authentication anyways.

My point is: I would love something that replaces Wordpress in simplicity for building completely custom content-backed websites for third parties that are not massive companies, I feel like there is nothing targeting that niche at the moment.

I’d prefer something that works with one of the existing excellent SSG solutions that there are, Astro is the one that comes to mind, the missing piece for me that I’ve seen no other CMS (except maybe Publii) do is actually doing the site builds on content change rather than giving you a webhook and pushing you towards setting that up with an additional third party service.

2 Likes