WaForgeDevelopers

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 #

  1. 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=manifest as the manifest URL. Copy the four values shown once.
  2. Download php.zip and open waforge-feed.php.
  3. 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).
  4. Upload the file to your web root. Open https://YOUR-SITE/waforge-feed.php?r=manifest in a browser: you should see JSON with your tenant id.
  5. 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.

waforge-feed.php (top of the file)
// ============================== 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) #

SQL
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 #

AddressSigned?Purpose
?r=manifestNoPublic manifest (no secrets)
?r=/catalog/search&q=...YesSearch by name or SKU, 1 to 50 results
?r=/products/{id}, ?r=/products/by-sku/{sku}YesOne product, or 404
?r=/availability (POST)YesLive stock for up to 50 items
?r=/orders/lookup (POST)YesOrder status, only if the phone matches
?r=/business/hours, ?r=/faqsYesOnly when WF_HOURS / WF_FAQS are filled
?r=selftestYesPHP 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:

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_SECRET right away.