thewildfields/tavriia
Composer 安装命令:
composer require thewildfields/tavriia
包简介
A reusable PHP framework providing a clean, typed, PSR-compliant OOP abstraction layer over WordPress core functions.
README 文档
README
A clean, typed, PSR-compliant OOP abstraction layer over WordPress core functions. Ships as a Composer package consumed by WordPress plugins.
What is Tavriia?
Tavriia is a framework that provides typed wrappers, contracts, and DTOs over raw WordPress APIs. It is not a plugin. It is a Composer library you pull into your plugin projects.
Without Tavriia:
$post = get_post($id); if (!$post instanceof \WP_Post) { // handle missing } $meta = get_post_meta($id, 'some_field', true); $result = wp_insert_post($args); if (is_wp_error($result)) { // handle error }
With Tavriia:
$post = $this->postRepository->findById($id); // throws PostNotFoundException or returns PostDTO $meta = $this->postRepository->metaFor($id)->getString('some_field'); $newId = $this->postFactory->create($dto); // throws or returns int
Installation
composer require thewildfields/tavriia
Requires PHP 8.2+ and WordPress (no minimum version enforced).
Quick Start
1. Create a module
use TheWildFields\Tavriia\AbstractModule; use TheWildFields\Tavriia\Post\PostFactory; use TheWildFields\Tavriia\Post\PostRepository; final class EventsModule extends AbstractModule { public function __construct( private readonly PostFactory $postFactory, private readonly PostRepository $postRepository, ) {} public function register_hooks(): void { add_action('init', [$this, 'registerPostType']); add_action('save_post_event', [$this, 'onSaveEvent'], 10, 2); } }
2. Create posts with typed DTOs
use TheWildFields\Tavriia\DTO\PostDTO; $dto = new PostDTO( title: 'Summer Concert', content: 'Annual summer concert in the park.', status: 'publish', postType: 'event', meta: ['venue_id' => 42], ); $eventId = $this->postFactory->create($dto);
3. Query posts fluently
use TheWildFields\Tavriia\Query\QueryBuilder; $results = (new QueryBuilder()) ->postType('event') ->metaQuery('venue_id', 42) ->orderBy('date', 'DESC') ->limit(10) ->get(); foreach ($results as $post) { echo $post->title; }
4. Make HTTP requests
use TheWildFields\Tavriia\Http\RequestBuilder; use TheWildFields\Tavriia\Http\HttpClient; use TheWildFields\Tavriia\Http\ResponseProcessor; $client = new HttpClient(new ResponseProcessor()); $response = $client->get('https://api.example.com/events'); $data = $response->json();
Features
| Area | Classes | Wraps |
|---|---|---|
| Posts | PostFactory, PostRepository, MetaManager |
wp_insert_post, wp_update_post, get_post, get_post_meta |
| Taxonomy | TermFactory, TermRepository, TermMetaManager |
wp_insert_term, get_terms, wp_get_object_terms |
| Queries | QueryBuilder, QueryResult |
WP_Query, get_posts |
| HTTP | HttpClient, RequestBuilder, ResponseProcessor |
wp_remote_get, wp_remote_post, wp_remote_request |
| REST | RestServer, RestRouteBuilder, RestResponse, AbstractRestController |
register_rest_route, WP_REST_Response, WP_Error |
| Admin | AdminMenuPage, AdminNotice |
add_menu_page, admin_notices |
| Modules | AbstractModule |
WordPress hooks lifecycle |
Design Principles
WP_Error never escapes the framework. Every wrapper converts WP_Error into a typed exception at the WordPress boundary. Plugin code never calls is_wp_error().
Factories return IDs, repositories return DTOs. PostFactory::create() returns int. PostRepository::findById() returns PostDTO or throws PostNotFoundException.
All concrete classes are final. Only AbstractModule and abstract base classes are non-final.
All DTOs are readonly. Immutable value objects with named constructors where appropriate.
Typed meta accessors. MetaManager::getString(), ::getInt(), ::getBool(), ::getArray() — never raw meta values.
Documentation
- Getting Started
- Core Concepts
- Modules
- Posts & Meta
- Taxonomy & Terms
- Query Builder
- HTTP Client
- REST API
- Admin Helpers
- Exception Handling
- API Reference
Contributing
This is a private framework package for The Wild Fields. See CLAUDE.md for architectural guidelines.
License
MIT
thewildfields/tavriia 适用场景与选型建议
thewildfields/tavriia 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「abstraction」 「plugin」 「wordpress」 「wp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 thewildfields/tavriia 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thewildfields/tavriia 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 thewildfields/tavriia 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
CakePHP 4.x AdminLTE Theme.
Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
ADOdb is a PHP database abstraction layer library
Slimmed down concise interfaces and query builder for database queries and transactions which can be layered / decorated.
MySQL Database abstraction
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-03