islamic-network/ilm-api-base
Composer 安装命令:
composer require islamic-network/ilm-api-base
包简介
Shared serving runtime for the ilm domain APIs: snapshot repository, DTO utilities, response cache, base controller and search scanner.
README 文档
README
The shared serving runtime for the ilm domain APIs (pray, events, people, quotes, stories). A domain API built on this package ships only what makes it that domain: its DTO classes (which ARE its contract), its Corpus (joins and projections), its controllers and routes. Everything domain-blind lives here:
Snapshot\Repository— pollssnapshots/manifest.jsonin the ilm bucket, loads the domain's snapshot file into worker memory when the version changes, maps it strictly into the domain's snapshot DTOs (drift throws; the last good version keeps serving), and constructs the domain Corpus. Configured viakipchak.snapshot: connection, bucket, prefix, refresh, plus the domain key and the Document/Corpus class names.Snapshot\CorpusInterface— what a domain corpus must expose (its snapshotversion); constructor convention($document, $version).Utils\Dto— strict valinor mapping in, array normalization out, with the contracts' "empty values are omitted" null-stripping (keepNullsfor the exceptions).Utils\Hijri— Gregorian → Hijri via the AlAdhan API (islamic-network/sdkIslamicCalendarClient, pinned toHJCoSA): the authoritative, sighting-adjusted date. Conversions are worker-memoized and disk-cached for a day; if AlAdhan is unreachable on a cold cache, ext-intl's tabularislamic-civilanswers as a logged fallback.ALADHAN_API_URLoverrides the endpoint.Middlewares\ResponseCache— disk cache for 200 GET responses (Kipchak filecache driver); keys carry the snapshot version so publishes invalidate naturally and a pod restart is a full flush.Controllers\SnapshotController—withCorpus()(503 on a cold worker), pagination, and the paginatedmetaenvelope via Kipchak'sResponse::json.Search\Scanner— the diacritic-folded search mechanism: query tokenization (folded exactly like the sync-timesearchblobs), AND-token matching, and per-fieldmatched_incomputation. Field maps per record type stay in each domain's Corpus.DataTransferObjects\Prose— the{raw, html}prose rendition shape every contract shares.
Wiring a domain API
// config/kipchak.snapshot.php
return [
'connection' => 'ilm',
'bucket' => env('S3_BUCKET', 'ilm'),
'prefix' => env('SNAPSHOT_PREFIX', 'snapshots'),
'refresh' => (int) env('SNAPSHOT_REFRESH', '60'),
'domain' => 'pray', // key in the manifest files map
'document' => Snapshot\Document::class, // strict-mapped snapshot DTO
'corpus' => Snapshot\Corpus::class, // implements CorpusInterface
];
Controllers extend SnapshotController; Middlewares\ResponseCache is added
in the app's global middleware stack before Kipchak's Error middleware.
pray-api is the reference consumer.
Developing
composer install
vendor/bin/phpunit
PHP 8.4+ (all ilm code stays 8.4-compatible), kipchak/core 3.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-13