PHP implementation of Wix API as an SDK.
composer require chkltlabs/wix-client
Requires PHP 8.2+.
Version 1.0 drops support for nimbly/shuttle 0.x, psr/http-message 1.x, and PHP versions below 8.2 to align with Laravel 13.
If you inject a custom HTTP client, no code changes are required. If you reference Shuttle or Capsule classes directly, update imports:
Shuttle\Shuttle→Nimbly\Shuttle\ShuttleShuttle\Handler\MockHandler→Nimbly\Shuttle\Handler\MockHandlerCapsule\Request→Nimbly\Capsule\RequestCapsule\Response→Nimbly\Capsule\Response
Shuttle 2.x no longer accepts a configuration array in its constructor; pass dependencies as named constructor arguments instead.
GitHub Actions runs the full PHPUnit suite on PHP 8.2, 8.3, and 8.4. PHP 8.2 also runs with --prefer-lowest to verify compatibility with minimum allowed dependency versions.
To run tests with pinned versions (without relying on host PHP/composer), use Docker:
docker compose up -d --build
docker compose exec wix-client composer install
docker compose exec wix-client ./vendor/bin/phpunit
To stop the container:
docker compose down
The use of this package is intentionally extremely basic, methods have no required inputs except where required by the underlying Wix API. Please see Wix API Docs for more information.
This package has only been tested using API Keys. Please see the Roadmap below for planned features.
To begin, instantiate the Wix class. Depending on the endpoints you plan to access, you may set one of account_id/site_id as a blank string (but not both).
use Chkltlabs\WixClient\Wix;
$api = new Wix(api_key: $my_api_key, account_id: $my_account_id, site_id: $my_site_id);
Now you have a class-based accessor to various api resources. These resources are treated as properties on the Wix class, or as properties of those properties:
//get all posts on the site's blog
$response = $api->blog->posts->list();
This structure aims to replicate the Wix API Docs as closely as possible.
For endpoints that do not yet have dedicated resource methods, use explicit domain resources:
//members domain
$response = $api->members->get('v1/members', ['limit' => 100]);
$response = $api->members->listMembersV1Members([], ['limit' => 100]);
//ecom domain
$response = $api->ecom->post('v1/orders/query', ['query' => []]);
$response = $api->ecom->getOrder(['id' => $orderId]);
//site actions domain
$response = $api->site_actions->post('v1/site-actions', ['action' => []]);
$response = $api->site_actions->bulkDeleteSite([], ['siteIds' => [$siteId]]);
Regenerate typed domain operation methods from Wix public docs:
python3 tools/generate_typed_resources.py --docs-root /tmp/wix-rest-docs
Generated from public docs currently available in wix-incubator/wix-rest-docs:
Api: 0Apps: 5Automations: 1B2BSiteManagement: 0Bookings: 118Chat: 1CurrencyConverter: 2DomainConnect: 0DomainSearch: 1Ecom: 24EmailMarketing: 20Events: 63EventsGuests: 0EventsPolicies: 5Faq: 11Forum: 5LocalDelivery: 7Locations: 6LoyaltyAccounts: 8LoyaltyPrograms: 2LoyaltyRewards: 4Marketing: 2MarketingConsent: 8Members: 27Notifications: 0Oauth: 0OauthApp: 5Payments: 8Pricing: 0PricingPlans: 35Progallery: 9PromoteSeoTxtFileServer: 2RedirectSession: 1Resellers: 8Restaurants: 36SiteActions: 0SiteFolders: 6SiteList: 1SiteMedia: 24SiteProperties: 9SocialGroups: 24Stores: 82V1: 1WixData: 44
All top-level domain resources in src/Resources are now explicit custom classes extending AbstractResource (no remaining top-level Domain subclasses).
- Blog
-
- Categories
- Drafts
- Posts
- Tags
- Business
-
- Location
- Properties
- Comments
- Contacts
-
- Bulk
- ExtendedFields
- Facets
- Labels
- Coupons
-
- Bulk
- Inbox
-
- Conversations
- Messages
- Marketing
- Media
- Members
- Site Content
- Automations
- Bookings
- Chat
- Data
- Events
- Forms
- Forum
- Groups
- Notifications
- Class method -> Route Documentation
- Cashier
- eCommerce
- Loyalty Program
- Payments
- Pricing Plans
- Restaurants
- Stores
- Payment Provider SPI
- Account Management
The Package uses a unified request system built on AbstractResource, so contributing new endpoints is as simple as creating a new class in src/Resources, and creating further subclasses is as simple as creating a new directory that matches your class name, and adding the HasCachedResources trait to your parent class. Make sure each extends AbstractResource.
Example from Blog.php:
//src/Resources/Blog.php
<?php
namespace Chkltlabs\WixClient\Resources;
use Chkltlabs\WixClient\Traits\HasCachedResources;
class Blog extends AbstractResource
{
use HasCachedResources;
}
//src/Resources/Blog/Posts.php
<?php
namespace Chkltlabs\WixClient\Resources\Blog;
use Chkltlabs\WixClient\Resources\AbstractResource;
class Posts extends AbstractResource
{
public function list(array $params = []): object
{
//...
}
//...
}
This package is heavily inspired and influenced by the excellent (TomorrowIdeas/Plaid)[https://github.com/TomorrowIdeas/plaid-sdk-php] SDK implementation. Go show them some love!