Download the PHP package contentstack/utils without Composer
On this page you can find all versions of the php package contentstack/utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download contentstack/utils
More information about contentstack/utils
Files in contentstack/utils
Package utils
Short Description Contentstack is a headless CMS with an API-first approach that puts content at the centre. It is designed to simplify the process of publication by separating code from content.
License MIT
Homepage https://github.com/contentstack/contentstack-utils-php
Informations about the package utils
Contentstack PHP Utils SDK:
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. Read More.
This guide will help you get started with Contentstack PHP Utils SDK to build apps powered by Contentstack.
Prerequisites
- PHP version 5.5.0 or later
SDK Installation and Setup
To set up the Utils SDK in your PHP project, install it via gem:
If you are using Contentstack PHP SDK, then “contentstack/utils” is already imported into your project.
Usage
Let’s learn how you can use Utils SDK to render embedded items.
Create Render Option:
To render embedded items on the front-end, use the renderOptions function, and define the UI elements you want to show in the front-end of your website, as shown in the example code below:
Basic Queries
Contentstack Utils SDK lets you interact with the Content Delivery APIs and retrieve embedded items from the RTE field of an entry.
Fetch Embedded Item(s) from a Single Entry:
Render HTML RTE Embedded object
To get an embedded item of a single entry, you need to provide the stack API key, environment name, delivery token, content type’s UID, and entry’s UID. Then, use the Contentstack::renderContent function as shown below:
If you want to render embedded items using the CustomOption function, you can refer to the code below:
Render Supercharged RTE contents
To get a single entry, you need to provide the stack API key, environment name, delivery token, content type and entry UID. Then, use Contentstack::jsonToHtml function as shown below:
If you want to render embedded items using the CustomOption function, you can refer to the code below:
Fetch Embedded Item(s) from Multiple Entries
Render HTML RTE Embedded object
To get embedded items from multiple entries, you need to provide the stack API key, environment name, delivery token, and content type’s UID.
Render Supercharged RTE contents
To get a single entry, you need to provide the stack API key, environment name, delivery token, content type UID. Then, use Contentstack::jsonToHtml function as shown below:
GQL
To Convert JSON RTE content to HTML from GQL API. Use GQL::jsonToHtml function as shown below:
Endpoint Resolution
The SDK ships with a built-in endpoint resolver that returns the correct Contentstack API URL for any region and any service — no hardcoded URLs needed.
How regions.json is provisioned
regions.json is not committed to your project. It is downloaded automatically:
| When | How |
|---|---|
composer install or composer update |
post-install-cmd runs scripts/download-regions.php |
First call to getContentstackEndpoint() when file is missing |
Runtime fallback downloads and caches the file |
| Manual refresh | composer refresh-regions |
getContentstackEndpoint()
Available on both Endpoint and Utils (identical behaviour):
| Parameter | Type | Default | Description |
|---|---|---|---|
$region |
string |
'us' |
Region ID or any accepted alias (see table below) |
$service |
string |
'' |
Service key. When empty, all endpoints for the region are returned as an array |
$omitHttps |
bool |
false |
When true, strips https:// from the returned URL(s) |
Supported Regions
| Region | Canonical ID | Accepted Aliases |
|---|---|---|
| AWS North America | na |
us, aws-na, aws_na, NA, US, AWS-NA, AWS_NA |
| AWS Europe | eu |
aws-eu, aws_eu, EU, AWS-EU, AWS_EU |
| AWS Australia | au |
aws-au, aws_au, AU, AWS-AU, AWS_AU |
| Azure North America | azure-na |
azure_na, AZURE-NA, AZURE_NA |
| Azure Europe | azure-eu |
azure_eu, AZURE-EU, AZURE_EU |
| GCP North America | gcp-na |
gcp_na, GCP-NA, GCP_NA |
| GCP Europe | gcp-eu |
gcp_eu, GCP-EU, GCP_EU |
Alias matching is case-insensitive and accepts both - and _ separators.
Available Service Keys
| Key | Description |
|---|---|
contentDelivery |
Content Delivery API (CDN) — for fetching published entries and assets |
contentManagement |
Content Management API — for creating and updating content |
graphqlDelivery |
GraphQL Delivery API |
graphqlPreview |
GraphQL Live Preview |
preview |
REST Live Preview |
auth |
Authentication API |
application |
Contentstack web application URL |
images |
Image Delivery |
assets |
Asset Delivery |
automate |
Workflow Automation API |
launch |
Contentstack Launch API |
developerHub |
Developer Hub API |
brandKit |
Brand Kit API |
genAI |
Generative AI / Knowledge Vault |
personalizeManagement |
Personalization Management API |
personalizeEdge |
Personalization Edge API |
composableStudio |
Composable Studio API |
assetManagement |
Asset Management API |
Examples
Get a single service URL
Use an alias instead of the canonical ID
Get a URL without the https:// scheme
Pass true as the third argument when you need just the hostname (e.g. for Stack::setHost()):
Get all endpoints for a region
Omit the $service argument to receive the full associative array:
Via Utils (same result, no import change needed)
Integration with the PHP Delivery SDK
Use getContentstackEndpoint() to resolve the host dynamically, then pass it to Stack::setHost():