Jump to content

I'm so glad I found Strapi...


bernhard
 Share

Recommended Posts

Hey ProcessWire friends!

@protro asked something about Strapi in another thread, so I did a quick research on how to build a basic frontend for content stored in Strapi and found this 20+ video on youtube:

Now, don't get me wrong, Strapi is cool and all and the video is really great, but I couldn't help but chuckle thinking about how we do basically the same in ProcessWire. Here's our "epic" version:

<?php
foreach($pages->find('template=faq') as $faq) {
    echo "<div><h2>{$faq->question}</h2>{$faq->answer}</div>";
}

Boom! Done in a few lines. No need for popcorn or a comfy chair. ?

Cheers to simplicity and efficiency! ?

#ProcessWireFTW #KeepItSimple #LessIsMore

  • Like 4
Link to comment
Share on other sites

If you prefer one-liners:

<?php
// https://processwire.com/api/ref/wire-array/each/
echo $pages->find('template=faq')->each("<div><h2>{question}</h2>{answer}</div>\n");

?

  • Like 5
  • Haha 1
Link to comment
Share on other sites

Posted (edited)

You may remember my question regarding a "Headless ProcessWire" quite a few months back.

The end result with either GraphQL, JSON, RestApi, and any other solution based on ProcessWire looked almost exactly like that when I wanted to use that data in either 11ty or Astro - which I used a lot back then.

So... yes, in plain ProcessWire this is a super simple no-brainer with 1 to 3 lines of minimal PHP.

Yet, when using anything else as the frontend, aka JS Framework (React, Svelte, Astro, 11ty) we still would have to go that route in some way or another.
Even with Hygraph, Payload, Directus, and whatever Headless CMS out there - it would look like that.

On 5/31/2024 at 1:04 AM, bernhard said:

I couldn't help but chuckle thinking about how we do basically the same in ProcessWire

The part you attribute to Strapi here is not really about Strapi. It's more about the used frontend. So... a bit off.

Probably more interesting and more comparable would be Laravel with Inertia JS (on the JS side of things) or Laravel with Livewire (on the side or similar to PW of things, from the creator of AlpineJS).
For that matter I really enjoy those Laravel-related videos from Aaron Francis (the PHP is cool again - guy) and the 30 days to learn Laravel Workshop.

 

Besides that we might want to ask better questions like:

  • Why use a (static) JS Frontend?
  • How to make PW more compatible with JS Frontend Frameworks?
Edited by wbmnfktr
typos
  • Like 5
Link to comment
Share on other sites

On 5/31/2024 at 5:49 PM, wbmnfktr said:
  • Why use a (static) JS Frontend?

I guess static really takes you long ways don't you think?? Kind of the same reason why ProCache is so successful and clouflare is a go-to solution to make any site faster.

Regular PHP can get resource intensive, I've experienced this a bit when having to do this 404 optimization , being hit by some bot still crawling wp-content/whatever.jpg it can choke a small server with relatively few concurrent requests. I'm nowhere close an expert at server optimization and leave this all to a 3rd parties like ploi when I can, so there's that too to consider along my experiences.

Maybe I'm just cheap on servers ? 

How to make PW more compatible with JS Frontend Frameworks?

Seems like similar CMSs with data-first approach like ProcessWire are using GraphQL for this purpose, and the modules in the ecosystem implement GraphQL queries too.  

In general the whole static js sites, api first approach seems way out of the league of the things I do, small to mid size corporate sites. Just thinking of adding a whole static project, with it's own dependencies, etc, it starts adding to the maintenance list lol. 

  • Like 1
Link to comment
Share on other sites

On 6/1/2024 at 1:49 AM, wbmnfktr said:

The part you attribute to Strapi here is not really about Strapi. It's more about the used frontend. So... a bit off.

I don't think it's off, because in ProcessWire we have both the Frontend and the Backend. As far as my research took me I don't think that Strapi offers that, does it? So you have to build your frontend on your own, add another tool and tech stack...

  • Like 1
Link to comment
Share on other sites

19 minutes ago, elabx said:

I guess static really takes you long ways don't you think?? Kind of the same reason why ProCache is so successful and clouflare is a go-to solution to make any site faster.

The question should have been more something like: Why does someone might want to use a (static) JS frontend?

But... yes, you are right. Those frontends, especially static, are great and help with lots of things. Not only 404s, crawlers and such but with security as well. If it wasn't for the hosting company to take measures, a client wouldn't have noticed someone tried to compromise his website.

Being cheap on servers (same for me) is something you can only do with ProcessWire or a static version of site. So a big plus here for ProcessWire. You can really squeeze a cheap hosting with ProcessWire and ProCache. Wouldn't want to try that with Wordpress or so.

24 minutes ago, elabx said:

Seems like similar CMSs with data-first approach like ProcessWire are using GraphQL for this purpose, and the modules in the ecosystem implement GraphQL queries too.  

GraphQL, Rest, JSON... is most of the time the way to go. Yet it seems people start to dislike GraphQL for some reason. Maybe because it's too much of a hassle for most. Don't know. And I am not sure how IntertiaJS does it in Laravel but maybe I will find out one day.

29 minutes ago, elabx said:

In general the whole static js sites, api first approach seems way out of the league of the things I do, small to mid size corporate sites. Just thinking of adding a whole static project, with it's own dependencies, etc, it starts adding to the maintenance list lol. 

I actually just did exactly that and moved smaller projects away from ProcessWire in the frontend. PW sits on cms.domain.tld and the frontend fetches JSON to generate everything. It's totally static and can be triggered via webhook to deploy a new version. It's more just for fun now.

One thing for sure (for me): building the first proof of concept or prototype with AstroJS reduces my initial development big times.

 

30 minutes ago, bernhard said:

I don't think it's off, because in ProcessWire we have both the Frontend and the Backend.

It's off because of that. Because Strapi doesn't do anything in the frontend and everything in the video was a JS framework.

Link to comment
Share on other sites

My only concern with using a JSON solution is, through my experience on Dreamhost and going back and forth with disabling mod_security for various issues, I noticed that Apache sometimes logged that it delivers the HTTP request, whereas if it's a PHP include/require or database query, it's all going to be run on a single PHP process (unless explicitly coded otherwise). If using JSON since Apache is handling a separate request, I think it has the possibility to spawn/create another PHP child process. Under normal scenarios this isn't a problem, but if you start getting hit with a bot attack of some sort (dictionary attack for wp-* pages, or DoS, or just a lot of 404s from a web scraper using old data [thanks, AWS]), you'll be increasing the spawn rate of PHP child processes much more quickly for any pages requesting data externally, and possibly hit a limit. Obviously caching can alleviate a lot of that - if you've taken the time to implement it. Just something to (possibly?) keep in mind. Realistically if you're getting attacked you'll still likely hit a limit eventually. ?

Since many of us like cheap hosts... ?

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...