publino/sdk
Composer 安装命令:
composer require publino/sdk
包简介
PHP client for the Publino headless delivery API.
README 文档
README
Zero-runtime-dependency PHP 8.2+ client for the Publino headless delivery API. Fetches published articles from a Publino site and returns typed DTOs.
📖 Full guide with framework examples (WordPress, Laravel): https://publino.de/sdk/php
Requirements
- PHP 8.2 or later
ext-curlandext-json(both bundled with standard PHP distributions)- Composer
Installation
composer require publino/sdk
Quick start
<?php require_once 'vendor/autoload.php'; use Publino\Sdk\PublinoClient; $client = new PublinoClient( baseUrl: 'https://api.publino.de', siteId: 'mein-blog', apiKey: getenv('PUBLINO_API_KEY'), // secret key (pub_live_…) — server only ); // List published articles → ArticleSummary[] $articles = $client->articles('de'); foreach ($articles as $a) { echo $a->title, " — ", $a->readingMinutes, " min\n"; } // Fetch a single article by "{slug}-{id}" or bare public id → ?Article $article = $client->article('hallo-welt-ab12cd34', 'de'); if ($article !== null) { echo $article->html; }
Security: the secret key (
pub_live_…) must stay server-side. For browser usage, use the publishable key (pub_pub_…) with theembed.jsweb components.
API
new PublinoClient(string $baseUrl, string $siteId, string $apiKey, int $timeout = 10, ?Transport $transport = null)
$baseUrl is the API origin (e.g. https://api.publino.de); the client appends
/v1/sites/{siteId}. Pass a custom Transport to use your own HTTP client; the default
is a bundled cURL transport.
articles(?string $locale = null): ArticleSummary[]
Returns all published articles, newest first. $locale defaults to the site's primary locale.
article(string $id, ?string $locale = null): ?Article
Returns the full article for a public id (bare id or "{slug}-{id}"), or null on 404.
DTOs
ArticleSummary: id, title, slug, locale, excerpt, metaDescription, canonicalUrl, publishedAt, readingMinutes (all readonly properties).
Article: the summary fields plus markdown, html, jsonLd — html is server-rendered and
sanitized; jsonLd is ready-to-embed Schema.org data (or null).
Errors
All exceptions extend Publino\Sdk\Exception\PublinoException:
UnauthorizedException(401) — bad / missing keyRateLimitedException(429) — exposesretryAfterApiException— other non-2xx, exposesstatusTransportException— network failure / invalid JSON
use Publino\Sdk\Exception\RateLimitedException; try { $articles = $client->articles('de'); } catch (RateLimitedException $e) { // back off for $e->retryAfter seconds }
Development
composer install composer test # phpunit
License
MIT © FameSystems GmbH & Co. KG
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-28