Data feed quickstarts
Plain PHP (one file)
One file, any PHP host (cPanel, Plesk, LiteSpeed, Apache, Nginx). PHP 8.0 or newer with PDO for MySQL, MariaDB, PostgreSQL or SQLite. No Composer, no framework, no rewrite rules.
Steps #
- Add the source. Dashboard, Data feeds, "Your website (live data)", type Data feed. Enter your domain and paste
https://YOUR-SITE/waforge-feed.php?r=manifestas the manifest URL. Copy the four values shown once. - Download php.zip and open
waforge-feed.php. - Edit the CONFIG block at the top of the file: your four values, a read-only database user, and your table and column names (example below).
- Upload the file to your web root. Open
https://YOUR-SITE/waforge-feed.php?r=manifestin a browser: you should see JSON with your tenant id. - Verify. In WaForge click Verify domain, add test values (a search word, a product id), then Run checks.
The CONFIG block #
The file already defines every constant with placeholder values. Edit them in place; do not add new lines.
// ============================== CONFIG ==============================
defined('WF_SECRET') || define('WF_SECRET', 'wf_fs_...'); // feed secret, shown once in the dashboard
defined('WF_KEY_ID') || define('WF_KEY_ID', 'fs_...');
defined('WF_TENANT') || define('WF_TENANT', 'wf_tn_...');
defined('WF_VERIFY') || define('WF_VERIFY', 'wfv_...');
// Use a READ-ONLY database user.
defined('WF_DB') || define('WF_DB', ['dsn' => 'mysql:host=localhost;dbname=shop;charset=utf8mb4', 'user' => 'waforge_ro', 'pass' => '...']);
defined('WF_BUSINESS') || define('WF_BUSINESS', [
'name' => 'My Shop',
'currency' => 'QAR', // ISO 4217 code of your prices
'prices_include_tax' => true,
'default_locale' => 'en',
'locales' => ['en', 'ar'],
'timezone' => 'Asia/Qatar',
]);
// Map YOUR table and column names. Set a column to null if you do not have it.
defined('WF_MAP') || define('WF_MAP', [
'products' => [
'table' => 'products',
'id' => 'id',
'sku' => 'sku',
'name' => 'name',
'description' => 'description',
'price' => 'price',
'stock' => 'stock', // quantity column, or null
'category' => 'category',
'url' => null, // full URL column, or null
'url_pattern' => 'https://myshop.example/product/{id}', // used when 'url' is null; {id} or {sku}
'image' => null, // full image URL column, or null
'active' => null, // 1/0 column to hide products, or null
'updated_at' => 'updated_at', // or null
],
'orders' => [ // set the whole entry to null to turn order lookups off
'table' => 'orders',
'number' => 'reference',
'phone' => 'customer_phone',
'status' => 'status',
'placed_at' => 'created_at', // or null
'tracking_url' => null,
],
]);Below the block you can also adjust WF_STATUS_MAP (your order statuses to WaForge statuses), WF_LOW_STOCK (default 3), and optional static WF_HOURS and WF_FAQS.
Create a read-only database user (MySQL) #
CREATE USER 'waforge_ro'@'localhost' IDENTIFIED BY 'a-long-random-password';
GRANT SELECT ON shop.products TO 'waforge_ro'@'localhost';
GRANT SELECT ON shop.orders TO 'waforge_ro'@'localhost';Routes the file serves #
| Address | Signed? | Purpose |
|---|---|---|
?r=manifest | No | Public manifest (no secrets) |
?r=/catalog/search&q=... | Yes | Search by name or SKU, 1 to 50 results |
?r=/products/{id}, ?r=/products/by-sku/{sku} | Yes | One product, or 404 |
?r=/availability (POST) | Yes | Live stock for up to 50 items |
?r=/orders/lookup (POST) | Yes | Order status, only if the phone matches |
?r=/business/hours, ?r=/faqs | Yes | Only when WF_HOURS / WF_FAQS are filled |
?r=selftest | Yes | PHP version, database reachable, which mapped columns were found |
Why ?r=? Query-string routing works on every host without rewrite rules, and the URL WaForge signs is exactly the URL PHP receives. The manifest sets base_url to https://YOUR-SITE/waforge-feed.php?r= automatically.
Test it #
Run the bundled tests locally (they use a temporary SQLite database): php tests/run.php. To call your live file with a valid signature from a terminal:
SECRET='wf_fs_...'; KID='fs_...'
URI='/waforge-feed.php?r=/catalog/search&q=card'
SIG=$(php -r '$t=time(); echo "t=$t,kid=".$argv[2].",v1=".hash_hmac("sha256", "$t\nGET\n".$argv[3]."\n".hash("sha256", ""), $argv[1]);' "$SECRET" "$KID" "$URI")
curl -s -H "WaForge-Signature: $SIG" "https://YOUR-SITE$URI"You should get {"data":{"items":[...]},"as_of":"...","ttl":300}. Sending the same header twice gives 401: that is the replay guard working. Then run the feed checker from the dashboard.
Safe by design #
- Column names are checked against the real table before any query; all values use prepared statements.
- Unknown order and wrong phone give the same 404.
- Replays are blocked with APCu when available, otherwise with small files in the system temp folder.
- Errors are logged with
error_log(), never shown to the caller. - The file accepts one secret. After you click "New secret" in WaForge, update
WF_SECRETright away.