{"id":36994465,"url":"https://github.com/contentstack/contentstack-php","last_synced_at":"2026-01-13T23:46:41.718Z","repository":{"id":45069710,"uuid":"76627555","full_name":"contentstack/contentstack-php","owner":"contentstack","description":"PHP SDK for Contentstack - Content Delivery API","archived":false,"fork":false,"pushed_at":"2026-01-05T10:01:37.000Z","size":2408,"stargazers_count":4,"open_issues_count":0,"forks_count":5,"subscribers_count":12,"default_branch":"master","last_synced_at":"2026-01-08T01:47:34.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/contentstack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-12-16T06:22:11.000Z","updated_at":"2026-01-05T06:32:30.000Z","dependencies_parsed_at":"2024-05-17T16:41:21.373Z","dependency_job_id":"4c8d63fe-eec2-4bd3-b86c-afbbeb1ed494","html_url":"https://github.com/contentstack/contentstack-php","commit_stats":{"total_commits":248,"total_committers":14,"mean_commits":"17.714285714285715","dds":0.6733870967741935,"last_synced_commit":"a6766d3b7636340ecab11dc5a87f4abddf4a74eb"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/contentstack/contentstack-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contentstack","download_url":"https://codeload.github.com/contentstack/contentstack-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-13T23:46:41.171Z","updated_at":"2026-01-13T23:46:41.713Z","avatar_url":"https://github.com/contentstack.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)\n\n## PHP SDK for Contentstack\n\nContentstack 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/). \n\nContentstack 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.\n\n\n### Prerequisite\n\nYou need PHP version \u0026gt;= 5.5.0 or later installed to use the Contentstack PHP SDK.\n\n### Setup and Installation\n\n#### Install the library using [Composer](https://packagist.org/packages/contentstack/contentstack):\nTo use the PHP SDK, you need to perform the following steps:\n\n    composer require contentstack/contentstack\n\nTo initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.\n\n```php\nuse Contentstack\\Contentstack;\n$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);\n```\nFor Setting the European Region:\nIf you want to set and use European region, refer to the code below:\n\n```php\nuse Contentstack\\Contentstack;\nuse Contentstack\\ContentstackRegion;\n$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME, array('region'=\u003e ContentstackRegion.EU));\n```\n#### Download and install library:\nTo use the PHP SDK, you need to perform the following steps:\n\n1. [Download](https://www.contentstack.com/docs/platforms/php/php_sdk_latest) the PHP SDK\n2. Create `dependencies` folder in your project directory\n3. Move this downloaded zip file to a `dependencies` folder\n4. Download the [MabeEnum](https://github.com/marc-mabe/php-enum)\n5. Create `marc-mabe` folder inside the `dependencies` folder\n6. Move the `php-enum` folder inside the `marc-mabe` folder\n\nTo initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.\n\n```php\ninclude_once __DIR__ . '/dependencies/contentstack/index.php';\nuse Contentstack\\Contentstack;\n$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);\n```\n\n\n### Key Concepts for using Contentstack\n\n#### Stack\n\nA stack is like a container that holds the content of your app. Learn more about [Stacks](https://www.contentstack.com/docs/guide/stack).\n\n#### Content Type\n\nContent 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).\n\n#### Entry\n\nAn 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). \n\n#### Asset\n\nAssets 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). \n\n#### Environment\n\nA 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). \n\n\n\n### Contentstack PHP SDK: 5-minute Quickstart\n\n#### Initializing your SDK \nInstall the library using [Composer](https://packagist.org/packages/contentstack/contentstack):\n\n    composer require contentstack/contentstack\n\n\nTo initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack.\n\n```php\nuse Contentstack\\Contentstack;\n$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);\n```\n\nTo get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings \u0026gt; Stack to view the API Key and Delivery Token.\n\n\n\n#### Querying content from your stack\n\nTo find all entries  of a content type, use the query given below:\n\n```php\n$result = $stack-\u003eContentType(CONTENT_TYPE_UID)-\u003eQuery()-\u003etoJSON()-\u003eincludeCount()-\u003eincludeContentType()-\u003efind();\n// $result[0] - array of entries\n// $result[1] - content type\n// $result[2] - count of the entries\n```\n\nTo fetch a specific entry from a content type, use the following query:\n\n```php\n$result = $stack-\u003eContentType(CONTENT_TYPE_UID)-\u003eEntry(ENTRY_UID)-\u003etoJSON()-\u003efetch();\n// $result - entry object\n```\n\n### Advanced Queries\n\nYou can query for content types, entries, assets and more using our PHP API Reference. \n\n[PHP API Reference Doc](https://www.contentstack.com/docs/platforms/php/api-reference/)\n\n  \n\n### Working with Images\n\nWe 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. \n\nFor 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, https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/download?crop=300,400. There are several more parameters that you can use for your images. \n\n[Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/). \n\nYou can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.\n\n// set the image quality to 100.\n\n```php\n$imageUrl = $stack-\u003eimageTransform(imageUrl, array('quality' =\u003e 100));\n```\n\n// resize the image by specifying width and height.\n\n```php\n$imageUrl = $stack-\u003eimageTransform(imageUrl, array(\n  'width' =\u003e 100,\n  'height' =\u003e 100\n));\n```\n\n// enable auto optimization for the image.\n\n```php\n$imageUrl = $stack-\u003eimageTransform(imageUrl, array('auto' =\u003e 'webp'));\n```\n\n\n### Helpful Links\n\n- [Contentstack Website](https://www.contentstack.com) \n- [Official Documentation](https://www.contentstack.com/docs) \n- [Content Delivery API Docs](https://www.contentstack.com/docs/apis/content-delivery-api/) \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentstack%2Fcontentstack-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontentstack%2Fcontentstack-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentstack%2Fcontentstack-php/lists"}