承接 barnythorpe/wp-config-containers 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

barnythorpe/wp-config-containers

最新稳定版本:0.3.0

Composer 安装命令:

composer require barnythorpe/wp-config-containers

包简介

A simple package with auto-generated builder and DTO classes for Wordpress Post Types and Taxonomies.

README 文档

README

Note

This package has been moved into https://github.com/Barny-Thorpe/fluent-wp

A Composer package for WordPress that provides strongly-typed DTO (Data Transfer Object) classes and Builder classes for various Wordpress configurations such as Post Types and Taxonomies.

This package helps bring structure, clarity, and type safety to WordPress projects by wrapping Post Type and Taxonomy configurations in clean, typed objects with fluent builder interfaces.

📖 About

This package auto-generates Builder Classes and in some cases DTOs for:

The generators read the DocBlocks of WordPress' native classes and automatically create various classes to help construct the above configurations in a clean and safe manner.

📦 Installation

You’ll need Composer installed.

composer require barnythorpe/wp-config-containers

🚀 Usage

use function Barnythorpe\WpConfigContainers\post_type;

$postType = post_type()
    ->name('my_custom_post')
    ->public(true)
    ->build();

$configArray = $postType->toArray();

See the Tests directory for more examples of how to use.

🛠️ Contributing & Developer Notes

If you're working on this package or maintaining it in the future, here’s what you need to know:

The Generator

  • Located in: src/WpConfigContainersGenerator/Generator.php
  • Uses:
    • phpDocumentor to parse DocBlocks and types
    • Twig templates to generate DTO and Builder class files
  • Templates:
    • src/WpConfigContainersGenerator/templates/dto.twig
    • src/WpConfigContainersGenerator/templates/builder.twig

To run the generator:

php generate.php

How It Works:

  • The Generator reflects on the original WordPress classes (WP_Post_Type, WP_Taxonomy).
  • It parses each property’s @var annotation to determine type and description.
  • Uses Twig or nette/php-generator to generate builder classes with fluent methods for setting those properties
  • Generated files are written to the src directory.

Testing

We use PestPHP for testing.
Tests are located in:

/tests/

Fixtures and test doubles are in:

/tests/Fixtures/

Run tests with:

./vendor/bin/pest

or

composer test

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-16