Download the PHP package incraigulous/contentful-laravel without Composer
On this page you can find all versions of the php package incraigulous/contentful-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download incraigulous/contentful-laravel
More information about incraigulous/contentful-laravel
Files in incraigulous/contentful-laravel
Package contentful-laravel
Short Description A Contentful SDK and toolkit for Laravel.
License MIT
Informations about the package contentful-laravel
DEPRECATED. Use Contentful's official PHP SDK.
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 for my Contentful PHP SDK used by this package.
New to Contentful? Contentful is an API driven CMS. Check out their website and API documentation.
Installation
Install via composer by running:
``
Update composer:
``
Next, add the following to the service providers array in config/app.php:
``
Configuration
Publish the config file:
``
This will add contentful.php to your /config folder.
Configuration Options
Key | Name | Description |
---|---|---|
space | Contentful API Space | Get this from the Contentful api panel |
token | Contentful API Token | Get this from the Contentful api panel |
oauthToken | Contentful oAuth Token | Needed for management SDK only |
cacheTag | Cache Tag | To make sure we can target and clear only Contentful items |
cacheTime | Cache Time | In minutes |
WebhookUrlBase | Webhook URL Base | The default URL base to use for webhooks generated by artisan command* |
WebhookUrlSuffix | Webhook URL Suffix | Will 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.
``
The following call would get the first 5 assets with a file size greater than or equal to 350000 bites.
``
Example calls using the management SDK
Creating a new content type:
``
Updating a content type
``
Click Here 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:
``
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:
``
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 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
.
``
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.
All versions of contentful-laravel with dependencies
illuminate/support Version ~5.0
incraigulous/contentful-sdk Version 0.0.*