PHPackages                             albertvds/laravel-wp-sync - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. albertvds/laravel-wp-sync

ActiveLibrary[API Development](/categories/api)

albertvds/laravel-wp-sync
=========================

Laravel service provider, query builder, and webhook bridge for the WordPress and WooCommerce REST APIs.

v0.1.0(4mo ago)02MITPHPPHP ^8.2

Since Mar 19Pushed 4mo agoCompare

[ Source](https://github.com/AlbertVDS/laravel-wp-sync)[ Packagist](https://packagist.org/packages/albertvds/laravel-wp-sync)[ RSS](/packages/albertvds-laravel-wp-sync/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

albertvds/laravel-wp-sync
=========================

[](#albertvdslaravel-wp-sync)

**Laravel integration for WordPress and WooCommerce**

Connects your Laravel application to the WordPress and WooCommerce REST APIs. Handles authentication, request building, response mapping, webhook verification, and local data sync.

[![PHP](https://camo.githubusercontent.com/6caa15003495643be73f70c6033009042189b7d38acf492a3d5fd04ffbb45059/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/6caa15003495643be73f70c6033009042189b7d38acf492a3d5fd04ffbb45059/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![Laravel](https://camo.githubusercontent.com/a31104b9c839e2d43bb53052e25dea353a50dcfdb39eef2c6c0bf5c95792db08/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d3130253230254332254237253230313125323025433225423725323031322d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/a31104b9c839e2d43bb53052e25dea353a50dcfdb39eef2c6c0bf5c95792db08/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d3130253230254332254237253230313125323025433225423725323031322d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)[![License](https://camo.githubusercontent.com/422db9fd40f5831c765cf6530b6750c081b696bd18d904cf89554df98c676277/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/422db9fd40f5831c765cf6530b6750c081b696bd18d904cf89554df98c676277/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666c61742d737175617265)[![Packagist](https://camo.githubusercontent.com/e7b0c42c527d74cd12df5ca33c1a6babf7858c49544884cc74f1e5108f4ee84b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c626572747664732f6c61726176656c2d77702d73796e633f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/e7b0c42c527d74cd12df5ca33c1a6babf7858c49544884cc74f1e5108f4ee84b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c626572747664732f6c61726176656c2d77702d73796e633f7374796c653d666c61742d737175617265)

---

Installation
------------

[](#installation)

```
composer require albertvds/laravel-wp-sync
```

The service provider and Facades register automatically via Laravel's package auto-discovery.

Publish the config file:

```
php artisan vendor:publish --tag=wp-sync-config
```

Add your credentials to `.env`:

```
WP_URL=https://your-site.com
WP_USER=your_username
WP_APP_PASSWORD=xxxx xxxx xxxx xxxx

WOO_URL=https://your-store.com
WOO_KEY=ck_xxxxxxxxxxxx
WOO_SECRET=cs_xxxxxxxxxxxx
```

---

What it does
------------

[](#what-it-does)

This package provides a service provider, Facade, fluent query builder, typed DTOs, and Artisan commands for working with the WordPress and WooCommerce REST APIs from within a Laravel application.

Incoming WooCommerce webhooks are received on an automatically registered route, verified against the HMAC-SHA256 signature, and dispatched as typed Laravel events. API responses are mapped to typed data objects rather than raw arrays. Frequently accessed resources can be cached using Laravel's existing cache configuration.

---

Features
--------

[](#features)

- **Fluent query builder** — filter, paginate, and retrieve WordPress posts, pages, and WooCommerce products, orders, and customers using a chainable API.
- **Typed DTOs** — API responses are returned as typed objects (`WpPost`, `WooOrder`, `WooProduct`, `WooCustomer`) with documented properties.
- **Webhook bridge** — registers a single route, verifies the request signature, maps the topic to a Laravel event class, and dispatches it. Supports all standard WooCommerce webhook topics.
- **Artisan commands** — `wp:sync` and `woo:sync` pull remote data into local database tables for offline querying.
- **Cache layer** — per-resource TTL configuration, backed by whichever Laravel cache driver the application already uses.
- **Multi-site support** — define multiple WordPress or WooCommerce connections in the config file and switch between them at runtime.
- **Auto-discovery** — the service provider and Facade register automatically via Composer's `extra.laravel` config. No manual setup required.

---

Usage
-----

[](#usage)

### WordPress

[](#wordpress)

Retrieve WordPress resources using the `Wp` Facade:

```
use Albertvds\WpSync\WpFacade as Wp;

// Fetch published posts
Wp::posts()->where('status', 'publish')->get();

// Fetch posts in a category, paginated
Wp::posts()->where('status', 'publish')->category('news')->paginate(10);

// Fetch a single post by slug
Wp::posts()->slug('my-post-slug')->first();

// Search posts
Wp::posts()->search('laravel')->get();

// Fetch pages
Wp::pages()->where('status', 'publish')->get();

// Fetch categories
Wp::categories()->get();

// Fetch media
Wp::media()->get();
```

### WooCommerce

[](#woocommerce)

Retrieve WooCommerce resources using the `Woo` Facade:

```
use Albertvds\WpSync\WooFacade as Woo;

// Fetch all processing orders
Woo::orders()->where('status', 'processing')->get();

// Fetch orders placed after a date, paginated
Woo::orders()->where('status', 'processing')->after('2024-01-01')->paginate(20);

// Fetch a single order by ID
Woo::orders()->find(42);

// Fetch in-stock products
Woo::products()->inStock()->get();

// Search products
Woo::products()->search('t-shirt')->paginate(15);

// Fetch customers
Woo::customers()->get();

// Fetch coupons
Woo::coupons()->get();

// Fetch product categories
Woo::categories()->get();
```

### Webhooks

[](#webhooks)

Point your WooCommerce webhook delivery URL at:

```
https://your-app.com/woo/webhook

```

The route is registered automatically — no changes to `routes/web.php` are needed. The package verifies the `X-WC-Webhook-Signature` header before processing any payload.

Listen to dispatched events anywhere in your Laravel application:

```
use Albertvds\WpSync\Events\OrderCreated;
use Albertvds\WpSync\Events\OrderUpdated;
use Albertvds\WpSync\Events\ProductUpdated;
use Albertvds\WpSync\Events\CustomerCreated;

// In EventServiceProvider or using #[AsEventListener]
Event::listen(OrderCreated::class, function (OrderCreated $event) {
    // $event->order is a typed WooOrder DTO
    Mail::to($event->order->billingEmail)
         ->send(new OrderConfirmationMail($event->order));
});

Event::listen(ProductUpdated::class, function (ProductUpdated $event) {
    // $event->product is a typed WooProduct DTO
    Cache::forget('product-'.$event->product->id);
});
```

To listen to all webhook events for logging or auditing purposes:

```
use Albertvds\WpSync\Events\WooWebhookReceived;

Event::listen(WooWebhookReceived::class, function (WooWebhookReceived $event) {
    Log::info('Webhook received', [
        'topic'   => $event->topic,
        'payload' => $event->payload,
    ]);
});
```

Supported webhook topics:

WooCommerce topicLaravel event`order.created``OrderCreated``order.updated``OrderUpdated``order.deleted``OrderDeleted``product.updated``ProductUpdated``customer.created``CustomerCreated`*(any other)*`WooWebhookReceived`### Artisan commands

[](#artisan-commands)

Pull remote data into local database tables for offline querying:

```
# Publish and run the sync migrations first
php artisan vendor:publish --tag=wp-sync-migrations
php artisan migrate

# Sync WordPress posts to the local wp_posts table
php artisan wp:sync posts

# Sync WordPress pages to the local wp_pages table
php artisan wp:sync pages

# Sync WooCommerce products to the local woo_products table
php artisan woo:sync products

# Sync WooCommerce orders to the local woo_orders table
php artisan woo:sync orders

# Sync WooCommerce customers
php artisan woo:sync customers
```

Schedule syncs in `routes/console.php`:

```
Schedule::command('woo:sync products')->hourly();
Schedule::command('wp:sync posts')->daily();
```

### Multi-site connections

[](#multi-site-connections)

Define multiple connections in `config/wp-sync.php`:

```
'connections' => [
    'store-nl' => [
        'url'    => env('WOO_NL_URL'),
        'key'    => env('WOO_NL_KEY'),
        'secret' => env('WOO_NL_SECRET'),
    ],
    'store-de' => [
        'url'    => env('WOO_DE_URL'),
        'key'    => env('WOO_DE_KEY'),
        'secret' => env('WOO_DE_SECRET'),
    ],
],
```

Switch between connections at runtime:

```
Woo::connection('store-de')->orders()->where('status', 'processing')->get();

Wp::connection('blog-nl')->posts()->where('status', 'publish')->paginate(10);
```

### Cache

[](#cache)

Configure TTL per environment in `.env`:

```
WP_SYNC_CACHE_TTL=300
```

Or per resource type in `config/wp-sync.php`:

```
'cache_ttl' => [
    'posts'    => 300,
    'products' => 60,
    'orders'   => 0,   // 0 disables caching for this resource
],
```

---

Configuration reference
-----------------------

[](#configuration-reference)

After publishing, `config/wp-sync.php` contains:

```
return [
    'wp' => [
        'url'          => env('WP_URL'),
        'user'         => env('WP_USER'),
        'app_password' => env('WP_APP_PASSWORD'),
    ],

    'woo' => [
        'url'    => env('WOO_URL'),
        'key'    => env('WOO_KEY'),
        'secret' => env('WOO_SECRET'),
    ],

    'webhook_path' => env('WOO_WEBHOOK_PATH', 'woo/webhook'),

    'cache_ttl' => env('WP_SYNC_CACHE_TTL', 300),

    'connections' => [],
];
```

---

Requirements
------------

[](#requirements)

DependencyVersionPHP8.2 · 8.3Laravel10 · 11 · 12WordPress REST API6.xWooCommerce REST API8.x---

Testing
-------

[](#testing)

```
composer test
```

The test suite uses [Pest](https://pestphp.com) and [Orchestra Testbench](https://github.com/orchestral/testbench). HTTP calls to the WordPress and WooCommerce APIs are intercepted with `Http::fake()` — no live credentials are required to run the tests.

---

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for recent changes.

---

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE) for details.

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance74

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

142d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c31490e48ab327f84dae2eb0c31a54c5da98033466821171eb315d2586785d79?d=identicon)[AlbertVDS](/maintainers/AlbertVDS)

---

Top Contributors

[![AlbertVDS](https://avatars.githubusercontent.com/u/10332563?v=4)](https://github.com/AlbertVDS "AlbertVDS (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/albertvds-laravel-wp-sync/health.svg)

```
[![Health](https://phpackages.com/badges/albertvds-laravel-wp-sync/health.svg)](https://phpackages.com/packages/albertvds-laravel-wp-sync)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818336.8k3](/packages/defstudio-telegraph)[api-platform/laravel

API Platform support for Laravel

58190.1k19](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5222.6k](/packages/simplestats-io-laravel-client)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1349.3k1](/packages/jasara-php-amzn-selling-partner-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
