jooservices / wordpress-sdk
A PHP 8.5 SDK with typed DTOs for stable WordPress REST resources
Requires
- php: ^8.5
- jooservices/client: ^4.5
- jooservices/dto: ^3.2
- jooservices/exceptions: ^4.0
- nyholm/psr7: ^1.8
- psr/log: ^3.0
Requires (Dev)
- captainhook/captainhook: ^5.23
- fakerphp/faker: ^1.24
- friendsofphp/php-cs-fixer: ^3.65
- laravel/pint: ^1.18
- phpmd/phpmd: ^3.0
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^13.0
- squizlabs/php_codesniffer: ^3.8 || ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-11 12:27:55 UTC
README
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()forshow_in_restcustom 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
- Knowledge base
- Getting started
- User guide
- Coverage matrix
- Upgrade from v1.x
- CI/CD workflows
- Changelog
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.