jooservices / wpsdk
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
Requires
- php: ^8.5
- jooservices/dto: ^1.0
- jooservices/jooclient: ^1.0
Requires (Dev)
- laravel/pint: ^1.0
- mockery/mockery: ^1.6
- phpmd/phpmd: ^2.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.0
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
- PHP 8.5+
- jooservices/dto - Immutable DTOs
- jooservices/jooclient - HTTP Client
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,UpdatePostDtoPageDtoMediaDtoUserDtoCategoryDtoTagDto
Development
# Install dependencies composer install # Run tests composer test # Run linters composer lint
License
Proprietary