PHPackages                             contentstack/contentstack - 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. contentstack/contentstack

ActiveLibrary[API Development](/categories/api)

contentstack/contentstack
=========================

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.

v2.4.2(5mo ago)459.7k↑33.7%6[3 PRs](https://github.com/contentstack/contentstack-php/pulls)MITPHPPHP &gt;=5.5.0CI failing

Since Mar 4Pushed 2w ago12 watchersCompare

[ Source](https://github.com/contentstack/contentstack-php)[ Packagist](https://packagist.org/packages/contentstack/contentstack)[ RSS](/packages/contentstack-contentstack/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (33)Used By (0)

[![Contentstack](https://camo.githubusercontent.com/2be23c3f4a9d91e33eeb97a58865093248a92e20455030ae01fb95a0a7297a91/68747470733a2f2f7777772e636f6e74656e74737461636b2e636f6d2f646f63732f7374617469632f696d616765732f636f6e74656e74737461636b2e706e67)](https://www.contentstack.com/)

PHP SDK for Contentstack
------------------------

[](#php-sdk-for-contentstack)

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](https://www.contentstack.com/).

Contentstack provides PHP SDK to build application on top of PHP. Given below is the detailed guide and helpful resources to get started with our PHP SDK.

### Prerequisite

[](#prerequisite)

You need PHP version &gt;= 5.5.0 or later installed to use the Contentstack PHP SDK.

### Setup and Installation

[](#setup-and-installation)

#### Install the library using [Composer](https://packagist.org/packages/contentstack/contentstack):

[](#install-the-library-using-composer)

To use the PHP SDK, you need to perform the following steps:

```
composer require contentstack/contentstack

```

To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.

```
use Contentstack\Contentstack;
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
```

For Setting the European Region: If you want to set and use European region, refer to the code below:

```
use Contentstack\Contentstack;
use Contentstack\ContentstackRegion;
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME, array('region'=> ContentstackRegion.EU));
```

#### Download and install library:

[](#download-and-install-library)

To use the PHP SDK, you need to perform the following steps:

1. [Download](https://www.contentstack.com/docs/platforms/php/php_sdk_latest) the PHP SDK
2. Create `dependencies` folder in your project directory
3. Move this downloaded zip file to a `dependencies` folder
4. Download the [MabeEnum](https://github.com/marc-mabe/php-enum)
5. Create `marc-mabe` folder inside the `dependencies` folder
6. Move the `php-enum` folder inside the `marc-mabe` folder

To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.

```
include_once __DIR__ . '/dependencies/contentstack/index.php';
use Contentstack\Contentstack;
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
```

### Key Concepts for using Contentstack

[](#key-concepts-for-using-contentstack)

#### Stack

[](#stack)

A stack is like a container that holds the content of your app. Learn more about [Stacks](https://www.contentstack.com/docs/guide/stack).

#### Content Type

[](#content-type)

Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. [Read more](https://www.contentstack.com/docs/guide/content-types).

#### Entry

[](#entry)

An entry is the actual piece of content created using one of the defined content types. Learn more about [Entries](https://www.contentstack.com/docs/guide/content-management#working-with-entries).

#### Asset

[](#asset)

Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets).

#### Environment

[](#environment)

A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).

### Contentstack PHP SDK: 5-minute Quickstart

[](#contentstack-php-sdk-5-minute-quickstart)

#### Initializing your SDK

[](#initializing-your-sdk)

Install the library using [Composer](https://packagist.org/packages/contentstack/contentstack):

```
composer require contentstack/contentstack

```

To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.

```
use Contentstack\Contentstack;
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
```

To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings &gt; Stack to view the API Key and Delivery Token.

#### Querying content from your stack

[](#querying-content-from-your-stack)

To find all entries of a content type, use the query given below:

```
$result = $stack->ContentType(CONTENT_TYPE_UID)->Query()->toJSON()->includeCount()->includeContentType()->find();
// $result[0] - array of entries
// $result[1] - content type
// $result[2] - count of the entries
```

To fetch a specific entry from a content type, use the following query:

```
$result = $stack->ContentType(CONTENT_TYPE_UID)->Entry(ENTRY_UID)->toJSON()->fetch();
// $result - entry object
```

### Advanced Queries

[](#advanced-queries)

You can query for content types, entries, assets and more using our PHP API Reference.

[PHP API Reference Doc](https://www.contentstack.com/docs/platforms/php/api-reference/)

### Working with Images

[](#working-with-images)

We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.

For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, . There are several more parameters that you can use for your images.

[Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/).

You can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.

// set the image quality to 100.

```
$imageUrl = $stack->imageTransform(imageUrl, array('quality' => 100));
```

// resize the image by specifying width and height.

```
$imageUrl = $stack->imageTransform(imageUrl, array(
  'width' => 100,
  'height' => 100
));
```

// enable auto optimization for the image.

```
$imageUrl = $stack->imageTransform(imageUrl, array('auto' => 'webp'));
```

### Helpful Links

[](#helpful-links)

- [Contentstack Website](https://www.contentstack.com)
- [Official Documentation](https://www.contentstack.com/docs)
- [Content Delivery API Docs](https://www.contentstack.com/docs/apis/content-delivery-api/)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance85

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~125 days

Recently: every ~252 days

Total

18

Last Release

170d ago

Major Versions

v1.8.1 → v2.0.02021-04-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a6dfbc6f69a25801755a0831a2c77e02b1289788fbf410ca3347a83a458143a?d=identicon)[Contentstack](/maintainers/Contentstack)

---

Top Contributors

[![uttamukkoji](https://avatars.githubusercontent.com/u/851830?v=4)](https://github.com/uttamukkoji "uttamukkoji (224 commits)")[![rohitmishra209](https://avatars.githubusercontent.com/u/19471077?v=4)](https://github.com/rohitmishra209 "rohitmishra209 (205 commits)")[![Aravind-Kumar-cstk](https://avatars.githubusercontent.com/u/19992950?v=4)](https://github.com/Aravind-Kumar-cstk "Aravind-Kumar-cstk (57 commits)")[![sunil-lakshman](https://avatars.githubusercontent.com/u/104969541?v=4)](https://github.com/sunil-lakshman "sunil-lakshman (39 commits)")[![mcarcangiu-ea](https://avatars.githubusercontent.com/u/46317657?v=4)](https://github.com/mcarcangiu-ea "mcarcangiu-ea (16 commits)")[![harshithad0703](https://avatars.githubusercontent.com/u/104908717?v=4)](https://github.com/harshithad0703 "harshithad0703 (14 commits)")[![hiteshbal91](https://avatars.githubusercontent.com/u/11676494?v=4)](https://github.com/hiteshbal91 "hiteshbal91 (10 commits)")[![contentstack-admin](https://avatars.githubusercontent.com/u/52040860?v=4)](https://github.com/contentstack-admin "contentstack-admin (8 commits)")[![harshitha-cstk](https://avatars.githubusercontent.com/u/267572082?v=4)](https://github.com/harshitha-cstk "harshitha-cstk (6 commits)")[![nandeesh-gajula](https://avatars.githubusercontent.com/u/69522367?v=4)](https://github.com/nandeesh-gajula "nandeesh-gajula (4 commits)")[![ondrejfuhrer](https://avatars.githubusercontent.com/u/10830505?v=4)](https://github.com/ondrejfuhrer "ondrejfuhrer (4 commits)")[![reeshika-h](https://avatars.githubusercontent.com/u/157372605?v=4)](https://github.com/reeshika-h "reeshika-h (2 commits)")[![cs-raj](https://avatars.githubusercontent.com/u/122264749?v=4)](https://github.com/cs-raj "cs-raj (1 commits)")[![nadeem-cs](https://avatars.githubusercontent.com/u/110535104?v=4)](https://github.com/nadeem-cs "nadeem-cs (1 commits)")[![mayankmishra](https://avatars.githubusercontent.com/u/175992?v=4)](https://github.com/mayankmishra "mayankmishra (1 commits)")

---

Tags

apiContentstack

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/contentstack-contentstack/health.svg)

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

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.5k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

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