A headless CMS is the opposite of a traditional CMS where both the front end and backend are loosely coupled. A headless CMS usually uses a RESTful API or a similar microservice architecture to display content on an app or a website.
ButterCMS uses JSON for each API call. Because of the microservice architecture, a headless CMS is platform independent. Whether you’re using Angular, React, Vue, Express or any other framework, the only thing that you need to do is make an API call to display the content.
Setting Up ButterCMS
To get started with ButterCMS, first thing that you need to do is sign up. ButterCMS is a paid platform. However, you do get a 30 days free trial.
Once you’ve signed up, you will need to choose a platform that you want to use ButterCMS on.
I tested this out with PHP. Overall it was pretty simple to setup. You will need to download the PHP API client from Github.
Once you sign up with ButterCMS, an example post and an example page would automatically be created for you.
Once you have downloaded the PHP API client, you will need to install Composer. Once Composer is installed, go to the path where composer.json is present in Command Prompt and run ‘composer install’.
Once composer is installed, you can test out if the API is working with a sample page.
You will need to create an API client object with your API token.
use ButterCMS\ButterCMS; $apiToken = 'your_api_token'; $client = new ButterCMS($apiToken);
I used the below code.
<?php require_once __DIR__ . '/vendor/autoload.php'; use ButterCMS\ButterCMS; $butterCms = new ButterCMS('my_api_token'); $response = $butterCms->fetchPost('example-post'); $post = $response->getPost(); echo $post->getTitle(); var_dump($post); ?>
If the API call works, then you will get a page displayed like the below.
The editor in ButterCMS works like any other editor where you can edit the content and publish it. The changes would get reflected wherever the API call is made.
Overall, ButterCMS is a pretty good CMS if you’re looking for a headless CMS. Their website has a pretty good article on how it’s different from WordPress and other traditional CMS.
P.S. PHP requires a server to run. I have used WampServer for this particular post.