Search by

jooservices / wordpress-sdk

jooservices

A PHP 8.5 SDK with typed DTOs for stable WordPress REST resources

Package info

github.com/jooservices/wordpress-sdk

pkg:composer/jooservices/wordpress-sdk

Statistics

Installs: 155

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v4.2.0 2026-10-11 11:15 UTC

This package is auto-updated.

Last update: 2026-10-11 12:27:55 UTC


README

CI Coverage (develop) Quality Gate (master) OpenSSF Scorecard PHP Version GitHub Release Packagist Version Total Downloads License: MIT

PHP 8.5 SDK with typed DTOs for stable WordPress REST resources and documented raw-array access for dynamic admin/editor schemas.

Package: jooservices/wordpress-sdk · v4.2.0 (ground-up rebuild)

Warning

v4.0.0 is a complete rebuild and is not backward compatible with archived v1.x. See About v4.0.0 and UPGRADE-4.0.md.

About v4.0.0

Status v4.2.0 — current release
First public line v4.0.0
Runtime PHP ^8.5, jooservices/client ^4.5, jooservices/dto ^3.2, jooservices/exceptions ^4.0

Features

  • Typed CRUD for posts, pages, media, comments, users, terms, settings, application passwords
  • Generic resource() / terms() for show_in_rest custom post types and taxonomies
  • Query DTOs, write payloads, REST enums, pagination (list / cursor / each)
  • Discovery, custom endpoints, batch, oEmbed, Gutenberg ContentBuilder
  • WordPress 7.1 core route-family coverage with a live Docker + WP-CLI E2E gate

Requirements

  • PHP ^8.5
  • jooservices/client ^4.5, jooservices/dto ^3.2, jooservices/exceptions ^4.0

Installation

composer require jooservices/wordpress-sdk

Quick start

use JOOservices\WordPress\Sdk\Data\Query\ListPostsQuery;
use JOOservices\WordPress\Sdk\Enums\PostStatus;
use JOOservices\WordPress\Sdk\WordPressService;

$wordpress = WordPressService::create(
    baseUrl: getenv('WORDPRESS_URL'),
    username: getenv('WORDPRESS_USER'),
    password: getenv('WORDPRESS_APP_PASSWORD'),
);

$posts = $wordpress->posts()->list(new ListPostsQuery(
    perPage: 10,
    search: 'automation',
    status: PostStatus::Publish,
    fields: 'id,title,link,date',
));

foreach ($posts as $post) {
    echo $post->title?->rendered . PHP_EOL;
}

WordPress application passwords are Basic auth — create() wires it. For bearer/JWT, build a jooservices/client instance and pass it to WordPressService::fromClient().

Media creates go through media()->upload(). JSON create() on media is rejected.

Custom post types and taxonomies:

$product = $wordpress->resource('product')->get(12);
$terms = $wordpress->terms('product_cat')->list();

Documentation

Development

All PHP tooling runs through Docker:

make install
make lint
make lint-fix
make test
make test-coverage
make integration
make integration-review-sample
make integration-review-cleanup
make ci

Unit tests use jooservices/client HTTP fakes (341 tests, 93.89% statements). make integration provisions disposable WordPress 7.1.3, MariaDB, and WP-CLI (4 live tests), then tears them down. make integration-review-sample runs the same suite and keeps a dedicated ContentBuilder sample post available at http://127.0.0.1:8080. To preserve an existing review stack, choose another project name and port, for example: WORDPRESS_REVIEW_PROJECT=wordpress-sdk-review-420 WORDPRESS_REVIEW_PORT=8081 make integration-review-sample. Set WORDPRESS_SDK_VENDOR_DIR to an absolute vendor directory when the test run must use an isolated Composer install. Run make integration-review-cleanup for the default review stack after review. Remove an alternate stack with docker compose --project-name <project> --file docker-compose.integration.yml --file docker-compose.integration-review.yml down --volumes.

Community

License

MIT