apiera / woo-php-sdk
This package is abandoned and no longer maintained.
No replacement package was suggested.
There is no license information available for the latest version (0.1.0) of this package.
Woo Rest API PHP SDK composer library
0.1.0
2025-02-14 14:05 UTC
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.9
- guzzlehttp/oauth-subscriber: ^0.8.1
- psr/http-message: ^2.0
Requires (Dev)
- apiera/php-standards: ^1.0
- dg/bypass-finals: ^1.9
- phpunit/phpunit: ^12.0
This package is auto-updated.
Last update: 2026-02-14 16:07:56 UTC
README
A lightweight PHP SDK for interacting with the WooCommerce REST API.
Requirements
- PHP 8.3 or higher
- A WooCommerce site with REST API enabled
- API consumer key and secret from WooCommerce
Installation
Install via Composer:
composer require apiera/woo-php-sdk
Basic Usage
use Apiera\WooPhpSdk\Client; use Apiera\WooPhpSdk\Configuration; use Apiera\WooPhpSdk\Enum\ApiVersion; // Create configuration $config = new Configuration( baseUrl: 'https://your-store.com', consumerKey: 'your_consumer_key', consumerSecret: 'your_consumer_secret', apiVersion: ApiVersion::V3, userAgent: 'My Application/1.0', timeout: 30 ); // Initialize client $client = new Client($config); try { // Get all products $products = $client->get('products'); // Create a product $newProduct = $client->post('products', [ 'name' => 'Test Product', 'type' => 'simple', 'regular_price' => '21.99' ]); // Update a product $updatedProduct = $client->put('products/123', [ 'name' => 'Updated Product Name' ]); // Delete a product $result = $client->delete('products/123'); } catch (\Apiera\WooPhpSdk\Exception\Http\HttpException $e) { $error = $e->getErrorMessage(); echo sprintf( "Error: [%s] %s", $error->getCode(), $error->getMessage() ); }
Error Handling
The SDK throws specialized exceptions for different HTTP error scenarios:
BadRequestException- 400 errorsUnauthorizedException- 401 errorsNotFoundException- 404 errorsInternalServerErrorException- 500 errorsRequestException- Other HTTP errors
All exceptions extend from HttpException which provides helpful methods to access request/response details:
try { $client->get('products/999'); } catch (\Apiera\WooPhpSdk\Exception\Http\HttpException $e) { echo $e->getRequestMethod(); // GET echo $e->getRequestUri(); // products/999 echo $e->getResponseStatusCode(); // 404 $error = $e->getErrorMessage(); echo $error->getCode(); // not_found echo $error->getMessage(); // Product not found print_r($error->getData()); // ['status' => 404] }
Development
Run tests:
composer test
Run coding standards check:
composer cs:check
Run static analysis:
composer static:analyse
Run all checks:
composer check
License
MIT License - see the LICENSE file for details.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.