Use Contentstack to power content for your PHP projects
Create PHP-based applications and use the PHP SDK to fetch and deliver content from Contentstack. The PHP SDK uses the Content Delivery APIs.
This guide will help you get started with our PHP SDK to build apps powered by Contentstack.
To get started with PHP, you will need the latest version of PHP (version 7.0.23 or above).
To use the PHP SDK, you need to perform the following steps:
Let's get started with the implementation.
You will need to specify the API Key, Delivery Token, and Environment Name of your stack to initialize the SDK.
``` use Contentstack\Contentstack; include_once "contentstack/index.php"; $stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME); ```
Once you have initialized the SDK, you can start getting content in your app.
To get a single entry, you need to specify the content type as well as the uid of the entry:
```bash $result = $stack->ContentType(CONTENT_TYPE_UID)->Entry(ENTRY_UID)->toJSON()->fetch() $result - entry object
To retrieve multiple entries of a content type, you need to specify the content type uid. You can also specify search parameters to filter results:
```bash $result = $stack->ContentType(CONTENT_TYPE_UID)->Query()->toJSON()->includeCount()->includeContentType()->find() $result - array of entries $result - content type $result - count of the entries ```
These were example of some of the basic queries of the SDK. For advanced queries, refer to our API reference documentation by visiting the link given below.
Go through our SDK API Reference guide to know about the methods that can be used to query your content in Contentstack.
The PHP SDK interacts with and uses our Content Delivery APIs to fetch content from Contentstack. Download the SDK to deliver content to your PHP projects.
To help you get started, we have created a sample application that is powered by Contentstack PHP SDK. Click on the link below to read the tutorial of the app, view app demo, or download the code from GitHub.