Monthly Archiv: August, 2020

When Does Using Headless WordPress Make Sense?

There’s a lot of talk these days about using headless WordPress. For the uninitiated, it’s the practice of utilizing a WordPress back end to feed content to an outside application. That might be a mobile app, a static website, a progressive web application or just about anything else a developer can dream up.

There are some real advantages to this configuration. The biggest may be that you can leverage the familiar content creation flow of WordPress. From there, that content can be used in any number of different places. Content creators don’t necessarily have to learn new software, while developers are able to utilize the best tools for the project – whether that’s WordPress or not.

Sounds pretty amazing, right? As powerful as a headless WordPress configuration can be, it’s not necessarily the right path for everyone. There are some potential drawbacks, not to mention a good bit of extra work to get all of your ducks in a row.

To really know if headless WordPress is right for your project, it’s important to consider the pros and cons, along with your goals. The following guide is here to help you make the best decision for your circumstances.

BUILD WORDPRESS SITES FASTER
Announcing Template Kits. Responsive WordPress Designs Built For Elementor.

What’s Different About Headless WordPress?

Technically speaking, a headless WordPress installation (sometimes referred to as a “decoupled” install) is just like any other. It still has the same server requirements and uses a database.

But there are a few key differences to be aware of:

WordPress Themes May Be Irrelevant

If you’re using WordPress exclusively as a means to feed content to an outside application, you may not be too concerned about the front end of your installation. That means you can stick with one of the default themes, such as Twenty Twenty.

Since you aren’t inviting visitors to your WordPress site, you might even decide to block access to the front end altogether.

You Can Use Plugins…To a Point

On a typical website, plugins are one of the main advantages of utilizing WordPress. They let you add all sorts of functionality with just a few clicks. But they take on a different meaning here.

Plugins that add functionality to a WordPress website generally aren’t going to carry over to whatever application you’re pushing content to. For instance, if you’re using a static site generator such as GatsbyJS, your install of WooCommerce isn’t going to let you run a store on that outside site – at least, not without some heavy lifting. The same goes for a contact form created via a plugin.

Yet plugins may still be used for other things. The outside app or website you’re pushing content to may require a plugin that allows for communication with WordPress. In addition, some plugins that are used to enhance the WordPress back end could still be helpful for content creation or workflow.

The WordPress REST API May Be Necessary

Pushing your content from WordPress to an outside source likely means that the REST API will be needed as well. Although, that may depend on just where you’re pushing content to. Other APIs may also be utilized.

The API makes your site’s pages, posts and more available as a JSON response. This format works with just about any language or library you’re using on your outside app or site – PHP, Node.js and Swift are prime examples.

While the API is turned on by default, there are scenarios when a developer might shut it off if it’s not being actively used. It’s just something to keep in mind should you decide to use a headless install.

A laptop computer.

Scenarios for Using Headless WordPress

Now that we know a bit more about what headless WordPress is and what makes it unique, let’s take a look at some scenarios for its use. Of course, these are just a few examples – you might find other projects where it’s a perfect fit.

Providing Content for a Mobile Application

If you need to feed your website’s content to a mobile app, headless WordPress is a great solution. Doing so creates consistency in your brand’s content and saves you from having to reinvent the wheel.

And, while we mentioned the possibility of using WordPress for content only, you don’t have to go that route. In fact, you can run a standard WordPress website – complete with a front end – while simultaneously pushing the site’s content to your mobile application.

This could be used, for instance, to make your website’s blog available to users of the mobile app. Or, if you run a membership site, any exclusive content and account management features could be ported over to an app as well.

Powering a Static Microsite

If you’re building a microsite for a product or service, one where you expect to receive a lot of traffic, a standard WordPress website may not be a good fit. All those database calls and memory-intensive operations can cripple a web server.

This is where a static website can make a lot of sense. Pages load lightning-quick, even on lower-level web hosting packages.

At the same time, you don’t want to make content management a pain for yourself or your client. With a headless WordPress configuration, content management is familiar. There’s no extra training required because creating pages and posts are the same as they’ve always been.

Interacting with a JavaScript UI

Progressive web applications offer powerful functionality right through a typical web browser. And they are often built with various flavors of JavaScript, such as React and Vue.

Once again, speed and ease of use are of great importance. Users will need to perform various tasks within the application, but without lag or other server-based delays. A traditional CMS is generally not recommended for this type of project.

Still, WordPress can be used to feed content into a progressive web app. Content can be pushed to the app and then cached for speedy load times. This provides a more natural feel to interactions and results in a better user experience.

A person using a mobile phone.

Times When Headless WordPress May Be Overkill

While this technique offers great flexibility, it’s not necessarily right for every occasion. Thus, it’s important to talk about the reasons for steering clear of headless WordPress.

For starters, utilizing headless WordPress can require a good bit of technical knowledge. This goes well beyond typical theme and plugin development. It might entail anything from using the command line to understanding how to interact with the REST API. The learning curve can be rather steep.

Then there’s the extra legwork you have to do to set it all up. Not only do you have to install and configure a copy of WordPress, you also have to think about the destination for your content. Static site generators, for example, do require their own unique configurations as well.

And, while it’s great to learn new things, there’s also a bottom line to worry about. For smaller, low-budget projects, going headless may just not be feasible.

A sad-looking cat.

Push Website Content Just About Anywhere

It’s easy to see why headless WordPress has become a trend. With a little elbow grease, you can take your website’s content and push it to just about any destination.

This also demonstrates the continued, and sometimes unexpected, flexibility of WordPress. Not only can it be used to build virtually any type of website, but also as a means to serve up content. And, because of its popularity, the development community continues to make the process easier.

Does a headless WordPress configuration make sense for your project? Hopefully this guide helps you make the best choice for your needs.

The post When Does Using Headless WordPress Make Sense? appeared first on Speckyboy Design Magazine.

Simple PHP Promise Library

Package:
Simple PHP Promise Library
Summary:
Register functions to call when conditions are met
Groups:
Language, PHP 5
Author:
Ahmad mustapha
Description:
This package can register functions to call when conditions are met...

Read more at https://www.phpclasses.org/package/11752-PHP-Register-functions-to-call-when-conditions-are-met.html#2020-08-09-19:56:17

Weekly News for Designers № 552

Envato Elements

A Lightweight Masonry Solution A nice lightweight solution from Ana Tudor. The minified JavaScript is under 800 bytes, while the strictly masonry-related styles are under 300 bytes.
A Lightweight Masonry Solution

What is the difference between this & that? Learn the the differences between ___ and ___ in front-end development.
What is the difference between this & that?

Deep Dive into CSS Grid Dive deep into the CSS Grid Layout and explore almost all related properties and features.
Deep Dive into CSS Grid

Modern CSS Techniques To Improve Legibility This detailed article covers how we can improve website legibility using some modern CSS techniques,

Getting the Most Out of Variable Fonts on Google Fonts

Mobile App UX Design Process
Mobile App UX Design Process

Growing Your Audience as a Designer We discuss the key principles that allow community builders to rise above others, and how you can learn from the examples they set.

macintosh.js Freely download Macintosh Quadra with Mac OS 8.1, together with a bunch of apps and games. It runs on JavaScript.
macintosh.js

μPlot.js A fast, memory-efficient Canvas 2D-based chart library for quickly plotting time series, lines, areas, ohlc and bar charts.
μPlot.js

How to Troubleshoot WordPress Website Email Issues
How to Troubleshoot WordPress Website Email Issues

Forge Icons A collection of 300+ free SVG icons for your next design project.
Forge Icons

What Does 100% Mean in CSS?
What does 100% mean in CSS?

Should a Web Designer Ever Provide Discounts? Discounting your services is not really a good move. But, there are some scenarios where it does make sense to offer a lower price for your web services.

System UIcons A free collection of 220 clean and simple icons that have been designed specifically for products. Use them how you want, without attribution.

Free MacBook Mockup Photoshop PSD Templates Take a look at some of the best free Macbook computer mockups (Photoshop PSD) curated here and add them all to your resource library.

The post Weekly News for Designers № 552 appeared first on Speckyboy Design Magazine.

Laravel Multi-Step Form

Package:
Laravel Multi-Step Form
Summary:
Create forms split in several pages for each step
Groups:
HTML, Libraries, PHP 5
Author:
Edward Paul
Description:
This package can create forms split in several pages for each step...

Read more at https://www.phpclasses.org/package/11748-PHP-Create-forms-split-in-several-pages-for-each-step.html#2020-08-06-18:12:13

PHP Internals News: Episode 66: Namespace Token, and Parsing PHP

PHP Internals News: Episode 66: Namespace Token, and Parsing PHP

In this episode of "PHP Internals News" I chat with Nikita Popov (Twitter, GitHub, Website) about his Namespaced Names as a Single Token, and Parsing PHP.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode's MP3 file, and it's available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news

Transcript

Derick Rethans 0:16

Hi, I'm Derick, and this is PHP internals news, a weekly podcast dedicated to demystifying the development of the PHP language. This is Episode 66. Today I'm talking with Nikita Popov about an RFC that he's made, called namespace names as token. Hello Nikita, how are you this morning?

Nikita 0:35

I'm fine Derick, how are you?

Derick Rethans 0:38

I'm good as well, it's really warm here two moments and only getting hotter and so.

Nikita 0:44

Same here. Same here.

Derick Rethans 0:46

Yeah, all over Europe, I suppose. Anyway, let's get chatting about the RFC otherwise we end up chatting about the weather for the whole 20 minutes. What is the problem that is RFC is trying to solve?

Nikita 0:58

So this RFC tries to solve two problems. One is the original one, and the other one turned up a bit later. So I'll start with the original one. The problem is that PHP has a fairly large number of different reserved keyword, things like class, like function, like const, and these reserved keywords, cannot be used as identifiers, so you cannot have a class that has the name list. Because list is also a keyword that's used for array destructuring. We have some relaxed rules in some places, which were introduced in PHP 7.0 I think. For example, you can have a method name, that's a reserved keyword, so you can have a method called list. Because we can always disambiguate, this versus the like real list keyword. But there are places where you cannot use keywords and one of those is inside namespace names.

So to give a specific example of code that broke, and that was my, my own code. So, I think with PHP 7.4, we introduced the arrow functions with the fn keyword to work around various parsing issues. And I have a library called Iter, which provides various generator based iteration functions. And this library has a namespace Iterfn. So Iter backslash fn. Because it has this fn keyword as part of the name, this library breaks in PHP 7.4. But the thing is that this is not truly unnecessary breakage. Because if we just write Iter backslash fn, there is no real ambiguity there. The only thing this can be is a namespace name, and similarly if you import this namespace then the way you actually call the functions is using something like fn backslash operator. Now once again you have fn directly before a backslash so there is once again no real ambiguity. Where the actual ambiguity comes from is that we don't treat namespace names as a single unit. Instead, we really do treat them as the separate parts. First one identifier than the backslash, then other identifier, then the backslash, and so on. And this means that our reserved keyword restrictions apply to each individual part. So the whole thing.

The original idea behind this proposal was actually to go quite a bit further. The proposal is that instead of treating all of these segments of the name separately, we treat it as a single unit, as a single token. And that also means that it's okay to use reserved keywords inside it. As long as like the whole name, taken together is not a reserved keyword. The idea of the RFC was to, like, reduce the impact of additional reserved keywords, introdu

Truncated by Planet PHP, read more at the original (another 18806 bytes)

PHP Internals News: Episode 65: Null safe operator

PHP Internals News: Episode 65: Null safe operator

In this episode of "PHP Internals News" I chat with Dan Ackroyd (Twitter, GitHub) about the Null Safe Operator RFC.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode's MP3 file, and it's available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news

Transcript

Derick Rethans 0:18

Hi, I'm Derick, and this is PHP internals news, a weekly podcast dedicated to demystifying the development of the PHP language. This is Episode 65. Today I'm talking with Dan Ackroyd about an RFC that he's been working on together with Ilija Tovilo. Hello, Dan, would you please introduce yourself?

Dan Ackroyd 0:37

Hi Derick, my name is Daniel, I'm the maintainer of the imagick extension, and I occasionally help other people with RFCs.

Derick Rethans 0:45

And in this case, you helped out Ilija with the null safe operator RFC.

Dan Ackroyd 0:50

It's an idea that's been raised on internals before but has never had a very strong RFC written for it. Ilija did the technical implementation, and I helped him write the words for the RFC to persuade other people that it was a good idea.

Derick Rethans 1:04

Ilija declined to be talking to me.

Dan Ackroyd 1:06

He sounds very wise.

Derick Rethans 1:08

Let's have a chat about this RFC. What is the null safe operator?

Dan Ackroyd 1:13

Imagine you've got a variable that's either going to be an object or it could be null. The variable is an object, you're going to want to call a method on it, which obviously if it's null, then you can't call a method on it, because it gives an error. Instead, what the null safe operator allows you to do is to handle those two different cases in a single line, rather than having to wrap everything with if statements to handle the possibility that it's just null. The way it does this is through a thing called short circuiting, so instead of evaluating whole expression. As soon as use the null safe operator, and when the left hand side of the operator is null, everything can get short circuited, or just evaluates to null instead.

Derick Rethans 1:53

So it is a way of being able to call a methods. A null variable that can also represent an object and then not crash out with a fatal error

Dan Ackroyd 2:02

That's what you want is, if the variable is null, it does nothing. If a variable was the object, it calls method. This one of the cases where there's only two sensible things to do, having to write code to handle the two individual cases all the time just gets a bit tedious to write the same code all the time.

Derick Rethans 2:20

Especially when you have lots of nested calls I suppose.

Dan Ackroyd 2:25

That's right. It doesn't happen too often with code, but sometimes when you're using somebody else's API, where you're getting structured data back like in an in a tree, it's quite possible that you have the first object that might be null, it's not null, it's going to point to another object, and the object could be null so and so so down the tree of the structure of the data. It gets quite tedious, just wrapping each of those possible null variables with a if not null.

Derick Rethans 2:55

The RFC as an interesting ex

Truncated by Planet PHP, read more at the original (another 22729 bytes)

Powered by Gewgley