clutch-property-mgmt/content-domain
最新稳定版本:1.3.2
Composer 安装命令:
composer require clutch-property-mgmt/content-domain
包简介
Shared CMS domain models for PHP SSR apps. Provides pure, framework-agnostic entities (Page, PageSection, Review, SeoMeta, Navigation, etc.) with attribute-based validation via [phpolar/model]. Designed for Clean Architecture: no infrastructure, no PDO—just content-focused domain objects.
README 文档
README
Shared CMS domain models for PHP SSR apps. Provides pure, framework-agnostic entities (Page, PageSection, Review, SeoMeta, Navigation, etc.) with attribute-based validation via [phpolar/model]. Designed for Clean Architecture: no infrastructure, no PDO—just content-focused domain objects.
Table of Contents
- Goals
- What’s Included
- What’s Not Included
- Install
- Usage
- Directory & Namespaces
- Versioning
- Contributing
- License
Goals
- Pure domain for CMS/content concerns
- Reusable across
storefront(read-only) andstorefront-admin(read-write) - Stable contracts with small, composable objects
- Validation via attributes using
phpolar/model - Zero infrastructure: no PDO, no frameworks, no I/O side effects
What’s Included
- Core CMS entities and value objects:
Page,PageSection,Block,SeoMeta,Slug,Navigation,MenuItem,Review(example set)
- Attribute-based rules for validation/normalization
- Minimal helpers for content-domain business rules (publishability, visibility windows, etc.) that do not perform I/O
What’s Not Included
- No repositories, PDO, or persistence code
- No controllers or framework glue
- No caching, logging, HTTP, or config loading
Keep infrastructure in the application layer (e.g.,
storefront,storefront-admin). This package should remain framework- and storage-agnostic.
Install
composer require clutch-property-mgmt/content-domain
Requires PHP 8.2+ and
phpolar/model.
Usage
Entities
<?php use ContentDomain\Content\Page; use ContentDomain\Content\SeoMeta; use ContentDomain\Content\PageSection; $seo = new SeoMeta(title: 'Apartments in Midtown', description: 'Spacious, modern units', keywords: ['apartments','midtown']); $page = new Page( id: null, slug: 'midtown-apartments', title: 'Midtown Apartments', sections: [ new PageSection('hero', ['headline' => 'Live in Midtown']) ], seo: $seo, publishedAt: new \DateTimeImmutable('2025-01-01T00:00:00Z'), );
Validation with phpolar/model
Use PHP attributes from phpolar/model on properties to enforce constraints.
<?php use Phpolar\Model\Attributes as Assert; final class Slug { public function __construct( #[Assert\NotBlank] #[Assert\Pattern('/^[a-z0-9-]+$/')] public readonly string $value, ) {} }
Immutability / Value semantics
Favor immutable value objects (e.g., Slug, SeoMeta) and explicit methods to derive new instances rather than in-place mutation. Entities may carry identifiers; value objects should not.
Directory & Namespaces
src/
Content/
Page.php
PageSection.php
SeoMeta.php
Slug.php
Review.php
Navigation.php
MenuItem.php
Validation/
(attribute helpers, if any)
- Root namespace:
ContentDomain\\... - Public API is limited to types under
ContentDomain\Contentand documented helpers.
Versioning
- Semantic Versioning (SemVer): MAJOR.MINOR.PATCH
- Breaking changes only in MAJOR releases
Contributing
- Fork and create a feature branch
- Add tests and docs
- Ensure CI passes (coding standards, static analysis, unit tests)
- Open a PR with a clear description and rationale
License
MIT License. See LICENSE for details.
统计信息
- 总下载量: 146
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2026-02-19