Skip to main content

Overview

This integration guide shows you how to how to update your existing project to:
  1. install the ButterCMS package
  2. instantiate ButterCMS
  3. create components to fetch and display each of the three ButterCMS content types: Pages, Collections, and Blog Posts.
In order for the snippets to work, you’ll need to setup your dashboard content schemas inside of ButterCMS first.

Starter project

Or, you can jump directly to the starter project below, which will allow you to clone, install, run, and deploy a fully working starter project that’s integrated with content already inside of your ButterCMS account.

Laravel Starter Project

Hit the ground running with a pre-configured Laravel + ButterCMS setup.

Installation

Add your API token to .env:
Add configuration to config/services.php:

Initialize the client

Register in AppServiceProvider:
For complete SDK documentation including all available methods and configuration options, see the PHP SDK Reference.

Pages

Localization

If your ButterCMS account has locales configured, pass the locale you want to fetch. Skip this if your account is single-locale — passing a locale that doesn’t exist on the account returns a 400 error.

Collections

Dynamic components

Component renderer

Example component

Using in pages

Blog

Routes

Preview mode

Caching

Webhook cache invalidation

SEO

Resources

Laravel Starter

Pre-configured starter project

PHP SDK

Complete SDK reference

GitHub Repository

View source code

Webhooks

Set up content webhooks