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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

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

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():

Switching regions without changing any other code


Error Handling


All versions of utils with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
marc-mabe/php-enum Version ^4.7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package contentstack/utils contains the following files

Loading the files please wait ...