PHPackages                             incraigulous/contentful-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. incraigulous/contentful-laravel

ActiveLibrary[API Development](/categories/api)

incraigulous/contentful-laravel
===============================

A Contentful SDK and toolkit for Laravel.

1.0(10y ago)171.7k1[3 issues](https://github.com/incraigulous/contentful-laravel/issues)MITPHPPHP &gt;=5.4.0

Since Mar 19Pushed 9y ago2 watchersCompare

[ Source](https://github.com/incraigulous/contentful-laravel)[ Packagist](https://packagist.org/packages/incraigulous/contentful-laravel)[ RSS](/packages/incraigulous-contentful-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/77bdbd8e9f912b2a87efc3cd472e7579c0542dc46867f3fb4353b0898707b1cb/68747470733a2f2f706f7365722e707567782e6f72672f696e6372616967756c6f75732f636f6e74656e7466756c2d6c61726176656c2f762f737461626c652e737667)](https://packagist.org/packages/incraigulous/contentful-laravel) [![Total Downloads](https://camo.githubusercontent.com/692ccb96d25240e33fc25b24debf5c02a27a2bf4ea55f3e8f43cce4651708cdb/68747470733a2f2f706f7365722e707567782e6f72672f696e6372616967756c6f75732f636f6e74656e7466756c2d6c61726176656c2f646f776e6c6f6164732e737667)](https://packagist.org/packages/incraigulous/contentful-laravel) [![Latest Unstable Version](https://camo.githubusercontent.com/d6d3c780d68a369bdabaa8d14068d27660b997e7007e0d1525830d864d34d5e3/68747470733a2f2f706f7365722e707567782e6f72672f696e6372616967756c6f75732f636f6e74656e7466756c2d6c61726176656c2f762f756e737461626c652e737667)](https://packagist.org/packages/incraigulous/contentful-laravel) [![Daily Downloads](https://camo.githubusercontent.com/61c9f4f1d6bf670be1a7670fea1e3704ef638ba560e9d0944c9a9a29c3c5926c/68747470733a2f2f706f7365722e707567782e6f72672f696e6372616967756c6f75732f636f6e74656e7466756c2d6c61726176656c2f642f6461696c792e706e67)](https://packagist.org/packages/incraigulous/contentful-laravel)

\#DEPRECATED. Use Contentful's official PHP SDK.

Laravel Contentful SDK and Toolkit
----------------------------------

[](#laravel-contentful-sdk-and-toolkit)

A Contentful SDK and suite of tools for Laravel. Includes facades, a base repository, out-of-the-box caching and cache management, webhook creation by artisan command and more.

\###This is a Laravel package.

\####Looking for the framework agnostic PHP SDK?

[Click Here](https://github.com/incraigulous/contentful-sdk) for my Contentful PHP SDK used by this package.

> ***New to Contentful?*** Contentful is an API driven CMS. Check out their [website](https://www.contentful.com/) and [API documentation](https://www.contentful.com/developers/documentation/content-delivery-api/).

\##Installation

Install via composer by running:

```
composer require "incraigulous/contentful-laravel:0.0.*"

```

Update composer:

```
composer update

```

Next, add the following to the service providers array in config/app.php:

```
'Incraigulous\Contentful\ContentfulServiceProvider',

```

\##Configuration

Publish the config file:

```
php artisan vendor:publish

```

This will add contentful.php to your /config folder.

\###Configuration Options

KeyNameDescriptionspaceContentful API SpaceGet this from the Contentful api paneltokenContentful API TokenGet this from the Contentful api paneloauthTokenContentful oAuth TokenNeeded for management SDK onlycacheTagCache TagTo make sure we can target and clear only Contentful itemscacheTimeCache TimeIn minutesWebhookUrlBaseWebhook URL BaseThe default URL base to use for webhooks generated by artisan command\*WebhookUrlSuffixWebhook URL SuffixWill be appended to the webhook URL base\*In addition to URLs, `WebhookUrlBase` also takes keywords for custom URL generation. You may specify `laravel` to generate the URL from the app:url configuration setting or `aws` to generate the URL based on the AWS public host name.

\####Obtaining your oAuth token

Instructions for generating an oAuth token can be found in Contentful's Management API documentation. If you are getting your key dynamically, you could create your own Facade for the Management SDK and load it there.

\##How to use it

\###Using the SDK

Adding the service provider will make two facades available:

**Contentful**: The content delivery SDK
**ContentfulManagement**: The management SDK

\####Example calls using the content delivery SDK

The following call would get the first 10 entries for a content type with the word *campus* in the title.

```
$result = Contentful::entries()
				->limitByType('CONTENT TYPE ID')
				->where('fields.title', 'match', 'campus')
				->limit(10)
				->get();

```

The following call would get the first 5 assets with a file size greater than or equal to 350000 bites.

```
$result = Contentful::assets()
              ->where('fields.file.details.size', '>=', 350000)
              ->limit(5)
              ->get();

```

\####Example calls using the management SDK

\#####Creating a new content type:

```
$result = ContentfulManagement::contentTypes()
                ->post(
                    new ContentType('Blog Post', 'title', [
                        new ContentTypeField('title', 'Title', 'Text'),
                        new ContentTypeField('body', 'Body', 'Text'),
                    ])
                );
            );

```

\#####Updating a content type

```
$contentType = ContentfulManagement::contentTypes()
					->find('CONTENT_TYPE_ID')
					->get();

$contentType['fields'][0]['name'] = 'Post Title';
$result = ContentfulManagement::contentTypes()->put('CONTENT_TYPE_ID', $contentType);

```

> [Click Here](https://github.com/incraigulous/contentful-sdk) for the full SDK documentation.

\####Caching All `GET` request results from the content delivery SDK are cached by default out of the box. `GET` request results from the management SDK are not cached to avoid update version conflicts.

\####Clearing your Contentful cache via webhook You must have have provided your oAuth key in your contentful.php configuration file to create webhooks. To create a new webhook for the cacher to listen for use the Artisan command:

```
php artisan contentful:create-webhook

```

This will create a webhook in Contentful that will post to your `/contentful/flush` route on any content updates. The package provides that route for you automatically and will flush Contentful items from your cache any time that route is posted to.

**Here's a trick:** The `/contentful/flush` route takes `get` or `post`, so you can clear your cache anytime by going to `/contentful/flush` in your browser.

What if you want to specify a custom webhook URL? Easy:

```
php artisan contentful:create-webhook  --url='http://www.myurl.com/webhook'

```

**Note:** Caching only works if your using the Redis and Memcached cache drivers.

\####Overriding CSRF Protection Laravel comes with cross site forgery protection, so you'll have to override it for the `/contentful/flush` route in order for the webhook to post to your site successfully. [Here's a guide](http://www.techigniter.in/tutorials/disable-csrf-check-on-specific-routes-in-laravel-5/) on how to do that.

\####Listening for webhooks If you autoscale your servers, you may need the ability to automatically create a webhook when a server is created and remove it when the server shuts down. You can do this by running the following command via `Supervisor`.

```
php artisan contentful:listen

OR

php artisan contentful:listen --url='http://www.myurl.com/webhook'

```

\###Contributing

**See a typo or a bug?** Make a pull request.
**What a new feature?** Make a pull request.
**Want a new feature and don't know how to build it?** You can always ask, I might be game if I think it's a good enough idea.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 97% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Total

5

Last Release

3916d ago

Major Versions

0.0.4 → 1.02015-08-29

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5910297?v=4)[Craig Wann](/maintainers/incraigulous)[@incraigulous](https://github.com/incraigulous)

---

Top Contributors

[![incraigulous](https://avatars.githubusercontent.com/u/5910297?v=4)](https://github.com/incraigulous "incraigulous (32 commits)")[![RemiCollin](https://avatars.githubusercontent.com/u/9589616?v=4)](https://github.com/RemiCollin "RemiCollin (1 commits)")

### Embed Badge

![Health badge](/badges/incraigulous-contentful-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/incraigulous-contentful-laravel/health.svg)](https://phpackages.com/packages/incraigulous-contentful-laravel)
```

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[spatie/laravel-route-discovery

Auto register routes using PHP attributes

23645.0k2](/packages/spatie-laravel-route-discovery)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[didww/didww-api-3-php-sdk

PHP SDK for DIDWW API 3

1218.2k](/packages/didww-didww-api-3-php-sdk)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
