Install ButterCMS in PHP

<?php namespace App; use Illuminate\Database\Eloquent\Model; use ButterCMS\ButterCMS; class Post extends Model { public static function fetchAll() { $result = self::butterCms()->fetchPosts(['page' => 1]); return $result->getPosts(); } public static function find($slug) { $response = self::butterCms()->fetchPost($slug); return $response->getPost(); } protected static function butterCms() { return new ButterCMS(env('BUTTER_CMS_API_KEY')); }
ButterCMS is a headless CMS that can be used in PHP. Here is a complete guide with code on integrating ButterCMS with PHP ( https://www.cloudways.com/blog/install-buttercms/ ).

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.