Getting started with Contentful and Laravel
This Laravel CMS tutorial will show you how to setup the Content Delivery API in your Laravel application and how to access your content inside the framework.
Requirements
The Contentful Laravel integration requires at least PHP 7.0.
Installation
The easiest way to install the Laravel integration is is to use Composer.
Enable the Service Provider
Next you need to enable the Service Provider by adding it to config/app.php:
Configuration
Before the PHP client library can be configured, the necessary config files have to be published. To do so execute the following command:
This will add a file called contentful.php to your /config folder. Now open it, and add at least your space ID and API key.
Using Contentful
You now have a service for the class Contentful\Delivery\Client available. A small controller displaying an entry based on an ID in the URL could look like this:
To discover how to use the Contentful client, check out the getting started with Contentful and PHP tutorial.
Conclusion
Now you should be familiar with the basics of how to use Contentful in a Laravel application. You can find the integration on GitHub and Packagist. To get a deeper understanding, read some of our other PHP tutorials. If you find a bug, or have an idea how to further integrate with Laravel, please open an issue on GitHub.