pollora/entity

A modern PHP package for WordPress custom post types and taxonomies

Installs: 1 878

Dependents: 1

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 0

Open Issues: 1

pkg:composer/pollora/entity

1.1 2025-09-26 09:32 UTC

README

A modern PHP 8.2+ library for easily managing WordPress custom post types and taxonomies with a fluent interface and hexagonal architecture.

Features

  • ๐Ÿš€ Modern PHP 8.2+ with type declarations
  • ๐Ÿ—๏ธ Fluent interface for easy configuration
  • ๐Ÿ”ง Built on top of Extended CPTs library
  • ๐Ÿ“ Hexagonal architecture for better separation of concerns
  • ๐Ÿงช Fully tested with PestPHP
  • ๐Ÿ’ก Intuitive method naming with dedicated methods for boolean properties

Installation

composer require pollora/entity

Documentation

Quick Start

Post Types

use Pollora\Entity\PostType;

PostType::make('book', 'Book', 'Books')
    ->public()
    ->showInRest()
    ->hasArchive()
    ->supports(['title', 'editor', 'thumbnail'])
    ->menuIcon('dashicons-book-alt');

Taxonomies

use Pollora\Entity\Taxonomy;

Taxonomy::make('genre', 'book', 'Genre', 'Genres')
    ->hierarchical()
    ->showInRest()
    ->showInQuickEdit();

Architecture

This package follows hexagonal architecture principles:

  1. Domain Layer: Core business logic (Entity, PostType, Taxonomy)
  2. Application Layer: Services that orchestrate operations
  3. Adapter Layer: WordPress integration adapters

The Domain layer remains independent of external dependencies, defining interfaces (ports) that adapters implement.

Testing

The package includes comprehensive unit tests using PestPHP with WordPress function mocks:

composer test

Test Structure

  • tests/helpers.php: Global WordPress function mocks
  • tests/ext_cpts_helpers.php: Extended CPTs namespace function mocks
  • tests/bootstrap.php: Test environment setup

License

This package is open-source software licensed under the MIT license.