contentpulse/contentpulse-php

The official PHP SDK for ContentPulse.io - content rendering, API client, and publishing utilities.

Maintainers

Package info

github.com/contentpulseio/contentpulse-php-sdk

pkg:composer/contentpulse/contentpulse-php

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-05-15 11:09 UTC

This package is auto-updated.

Last update: 2026-05-19 21:07:36 UTC


README

CI

Official PHP SDK for ContentPulse.io - content rendering, API client, and publishing utilities.

Requirements

  • PHP 8.2+

Installation

composer require contentpulse/contentpulse-php

Quick Start

Create a client

use ContentPulse\Http\ContentPulseClient;

$client = new ContentPulseClient(
    baseUrl: 'https://contentpulse.io',
    apiKey: 'your-api-key'
);

Resolve WordPress endpoints (SDK-managed)

use ContentPulse\WordPress\Support\ContentPulseEndpointResolver;

$apiBaseUrl = ContentPulseEndpointResolver::resolveApiBaseUrlFromEnvironment();
$appBaseUrl = ContentPulseEndpointResolver::resolveAppBaseUrlFromEnvironment();
$publishEndpoint = ContentPulseEndpointResolver::buildPublishWordPressEndpoint($apiBaseUrl, $contentId);
$contentUrl = ContentPulseEndpointResolver::buildContentUrl($appBaseUrl, $contentId);

When no overrides are provided, the resolver auto-selects sensible defaults:

  • Local/dev: http://contentpulse.test:8080 and http://app.contentpulse.test:5173 (when contentpulse.test is resolvable)
  • Otherwise: https://contentpulse.io and https://app.contentpulse.io

Overrides (highest to lowest precedence): explicit argument → PHP constant (CONTENTPULSE_API_URL, CONTENTPULSE_APP_URL) → environment variable.

Fetch content feed

use ContentPulse\Core\DTO\ContentFilters;

$feed = $client->getContentFeed(new ContentFilters(
    websiteId: 1,
    perPage: 20,
));
foreach ($feed->items as $item) {
    // $item contains content metadata and structure
}

Render content to HTML

use ContentPulse\Rendering\HtmlRenderer;

$renderer = new HtmlRenderer();
$html = $renderer->renderAll($content->sections);

Section normalizer

use ContentPulse\Rendering\SectionNormalizer;

$normalizer = new SectionNormalizer();
$normalized = $normalizer->normalize($rawSections);

SEO meta tags

use ContentPulse\Core\DTO\SeoMeta;

$seo = SeoMeta::fromArray($content->seo_metadata);
$html = $seo->toHtml(); // Renders <title>, meta description, og:*, twitter:*

Publish payloads

Build platform-specific payloads for WordPress or Shopify:

use ContentPulse\Publishing\PublishPayloadBuilder;
use ContentPulse\Rendering\HtmlRenderer;

$builder = new PublishPayloadBuilder(new HtmlRenderer());
$payload = $builder->buildForWordPress($content);
// or
$payload = $builder->buildForShopify($content);

Architecture

Module Purpose
Core/Contracts/ Interfaces for API client, renderers, and publishers
Core/DTO/ Data transfer objects (CompatibilityInfo, PublicationRecord, SeoMeta, PublishResult)
Core/Exceptions/ Exception hierarchy for API and validation errors
Http/ REST API client for ContentPulse endpoints
Rendering/ HtmlRenderer, SectionNormalizer, SEO meta renderer
Publishing/ Publish payload builder for WordPress, Shopify, and custom platforms

Supported Section Types

The HtmlRenderer supports all section types produced by the ContentPulse content generation pipeline:

Fixed sections: titles, hero, cta, seo_keywords, references

Content sections: content, content_seo, conclusion

Component sections: steps, table, grid, checklist, faq, dos_donts, alert, quote, pros_cons, summary_box, definition, key_stats, tip_box, comparison_card, comparison_table, timeline, accordion, testimonial, code_snippet

Testing

composer test

Or directly:

./vendor/bin/phpunit

License

MIT