woothemes/woocommerce-api
PHP client wrapper for the WooCommerce REST API. Create a WC_API_Client with your store URL and API keys to fetch the API index, list/filter orders, and retrieve single orders. Supports debug output, array responses, timeouts, URL validation, and exceptions with request/response details.
Pros:
orders->get(), products->create()) align with Laravel’s service-layer patterns, enabling clean separation of concerns.order.created) via API webhooks or polling.Cons:
WC_API_Client_Exception to Laravel’s HttpException or ApiException).queue:work).ssl_verify: false is enabled by default in examples. Mitigation: Enforce SSL verification in production and use Laravel’s TrustProxies middleware for proxy setups.Cache::remember()) or use a queue (e.g., dispatch(new SyncOrdersJob())).automattic/woocommerce).automattic/woocommerce is actively maintained and Laravel-compatible. Compare features (e.g., webhook support, GraphQL).retry() helper) or caching.consumer_key/consumer_secret in Laravel’s .env or a secrets manager (e.g., AWS Secrets Manager).Laravel Compatibility:
Http facade or Guzzle to wrap the library (e.g., Http::withOptions(['debug' => true])->post(...)).$this->app->singleton(WC_API_Client::class, function ($app) {
return new WC_API_Client(
config('woocommerce.url'),
config('woocommerce.consumer_key'),
config('woocommerce.consumer_secret'),
['timeout' => 30, 'ssl_verify' => env('APP_DEBUG') ? false : true]
);
});
event(new OrderSynced($order))).Database Sync:
woocommerce_orders).Observers or Model Events to trigger API calls (e.g., created: Order → push to WooCommerce).Phase 1: Proof of Concept (PoC)
GET /orders, POST /products).Phase 2: Core Integration
WooCommerceService facade to abstract API calls.
class WooCommerceService {
public function __construct(private WC_API_Client $client) {}
public function createOrder(array $data): Order {
$response = $this->client->post('orders', $data);
return new Order($response->get_body());
}
}
Phase 3: Advanced Features
new_order → HandleWooCommerceOrder).SyncProductsJob).logs table or a third-party tool (e.g., Sentry).php-compat) if needed.consumer_key/consumer_secret in WooCommerce → WP Admin → WooCommerce → Settings → Advanced → REST API..env:
WOOCOMMERCE_URL=https://store.com
WOOCOMMERCE_CONSUMER_KEY=ck_...
WOOCOMMERCE_CONSUMER_SECRET=cs_...
GET /orders and POST /products.WC_API_Client_Exception to Laravel’s HttpException.Horizon for queue monitoring and Laravel Debugbar for API debugging.automattic/woocommerce.debug: true in options for detailed logs.Log facade to capture API errors.How can I help you explore Laravel packages today?