From a Working Demo to a Maintained Bot

Raw MD
Test matrices, error diagnosis, retries, performance and release verification.

A successful /start response proves one route worked. It does not prove uploads, callbacks, permissions, cron and error recovery are ready. Use this guide to expand testing without claiming that helper availability equals complete live coverage.

Before the first live test

Choose a dedicated test bot. Configure its own token and administrator ID. Confirm that the hosted PHP version is the one expected; cPanel's selected version, a webhook request and a cron interpreter may differ. Use the exact entrypoint you will deploy.

For helper code, put tg_all_fun(); after declare(strict_types=1); and before the first helper call. For plain PHP, use your own request function and do not call native helper names. Keep a fresh copy of the deployed code and record which runtime version is installed.

Test matrix

Area Test Evidence
Loading No loader, then explicit loader Public helpers absent, then present
Identity getMe Expected bot username
Text Text send and long/untrusted input Correct escaping and bounded output
UI Press a real callback button Callback acknowledgement and correct actor
Editing Edit a newly created test message Returned message or accepted result
Media Upload, reuse same-bot ID, download API result plus local file verification
Storage Restart/request separation State persists without global variables
Cron Run the actual scheduled entrypoint Correct runtime, credentials and log
Permissions Group/channel test resources Allowed and denied actions handled
Failure Invalid target, rate limit, timeout Error recorded without leaking secrets
Deployment Change, verify, rollback code Data and credentials preserved

For rich messages, emoji and effects, also inspect the Telegram client. API acceptance cannot establish visual appearance. For business, payment, inline and widget flows, create the corresponding authorized setup; otherwise mark the test NOT_TESTED.

Interpret errors by layer

Symptom Layer to inspect First action
Undefined tg_allfun Bot spelling Use tg_all_fun exactly
Undefined tg_send Loading/order Call loader before use; verify deployed runtime
Undefined tg_all_fun Runtime/entrypoint Check deployment and standalone versus hosted execution
Missing required PHP file Release consistency Deploy matching files, verify path
snmp.so library missing Hosting PHP startup Ask hosting to repair extension dependencies
MySQL 1045 Platform database authentication Verify configured credentials and database user access
Bad Gateway API/network response Record method and timestamp, use bounded recovery
429 retry_after API rate limiting Schedule retry after indicated delay
Timeout Network or execution budget Check elapsed time; do not assume an operation did not happen
SQLite locked Database concurrency Shorten transactions and inspect competing writers

Compare fresh timestamps. An old error before a later successful release is not proof that the current code still fails. Keep logs useful by recording operation names and result categories without token-bearing URLs or full private updates.

Retry and work queues

A bounded retry can be appropriate for a read-only lookup. A payment or destructive operation needs stronger handling because a timeout can occur after the server performed it. Persist a job's progress, attempt count and next eligible time. Stop rather than spin when the API returns a rate limit.

Avoid long sleep loops in a webhook. Keep the request bounded and move large broadcasts/imports into scheduled batches. Use an application lock or job claim so overlapping cron invocations do not process the same batch simultaneously. Do not assume the PHP max_execution_time setting is the only host limit.

Measure performance fairly

OPcache caches compiled PHP; it does not cache Telegram responses or automatically eliminate all application work. A loaded extension does not prove that a particular pool has effective caching. Check the actual runtime and compare the same operation under similar conditions.

Measure application preparation, database work and outgoing API calls separately. Collect multiple samples and compare median and slower-tail latency. Do not compare the total time for fifteen API tests with one normal bot reply. The loader registers helpers; it does not itself send a request. No fixed milliseconds or cross-language speed guarantee is made here.

Release and rollback

Add the compatibility loader guard to existing helper bots before switching the platform runtime. Deploy matching core files in a maintenance window. Preserve .env and database.db; a code rollback is not an instruction to overwrite new user data with an old database.

After deployment, test a normal PHP bot, a helper bot, a hosted cron, the platform dashboard and the error-log route. If using timestamp-based OPcache validation, allow its configured refresh behavior or use an authorized cache restart. Remove temporary diagnostic pages after use.

See deployment checklist, operations, and PHP OPcache configuration.