PHP SDK for WordPress REST API with type-safe DTOs

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/jooservices/wpsdk

1.0.0 2026-01-10 09:18 UTC

This package is auto-updated.

Last update: 2026-01-10 09:22:03 UTC


README

PHP SDK for WordPress REST API with type-safe DTOs.

Requirements

Installation

composer require jooservices/wpsdk

Quick Start

use JOOservices\WpSDK\SdkManager;
use JOOservices\WpSDK\Authentication\ApplicationPasswordAuth;

// Create SDK instance
$sdk = SdkManager::create('https://example.com')
    ->authenticate(new ApplicationPasswordAuth('admin', 'xxxx xxxx xxxx xxxx'));

// Get posts
$response = $sdk->client()->get('/posts', ['per_page' => 10]);
if ($response->isSuccess()) {
    $posts = $response->getContent();
}

// Create a post
$response = $sdk->client()->post('/posts', [
    'title' => 'Hello World',
    'content' => 'Post content here',
    'status' => 'publish',
]);

Authentication

Application Password (Recommended)

use JOOservices\WpSDK\Authentication\ApplicationPasswordAuth;

$auth = new ApplicationPasswordAuth('username', 'xxxx xxxx xxxx xxxx');
$sdk->authenticate($auth);

Basic Authentication

use JOOservices\WpSDK\Authentication\BasicAuthentication;

$auth = new BasicAuthentication('username', 'password');

JWT Authentication

use JOOservices\WpSDK\Authentication\JwtAuthentication;

$auth = new JwtAuthentication('your-jwt-token');

DTOs

The SDK provides immutable DTOs for WordPress entities:

use JOOservices\WpSDK\DTOs\Post\PostDto;
use JOOservices\WpSDK\DTOs\Post\CreatePostDto;

// Create from array
$post = PostDto::fromArray($response->getContent());

// Access properties
echo $post->title;
echo $post->status;

// Convert to array/JSON
$array = $post->toArray();
$json = $post->toJson();

Available DTOs

  • PostDto, CreatePostDto, UpdatePostDto
  • PageDto
  • MediaDto
  • UserDto
  • CategoryDto
  • TagDto

Development

# Install dependencies
composer install

# Run tests
composer test

# Run linters
composer lint

License

Proprietary