Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pollora/WordPressEntity

Repository files navigation

Pollora Entity WordPress Package

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.

About

Create WordPress post types and taxonomy in a fluent way

Resources

License

Stars

Watchers

Forks

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /