# Explicit Telegram helper loading — deployment

Hosted bot code now calls `tg_all_fun();` before any `tg_*` helper. Place it after `declare(strict_types=1);` when that declaration is used. A bot using only its own PHP/cURL can omit the call. No file path or extra include is required. Repeated calls are safe.

The core platform transport and PHP loader remain present. The public helper functions are registered only when requested in hosted webhook and isolated child-cron requests. This does not eliminate compilation of the containing PHP file and is not a measured speed optimization. Platform pages explicitly load helpers for their own operations.

## Migrate existing bots before changing the runtime

First add this transition line to every helper-based bot and child cron entrypoint, after strict_types and before its first helper call:

```php
if (function_exists('tg_all_fun')) {
    tg_all_fun();
}
```

It works with the old eager-loading runtime and the new opt-in runtime. Once the runtime is deployed, new bot code can use simply `tg_all_fun();`. Existing bots that omit the loader will get undefined-function errors. Do not overwrite unrelated user code. Custom functions with the same names as the helper suite must not be mixed with the suite.

## Runtime files (deploy together)

- includes/telegram.php
- includes/bootstrap.php
- webhook.php
- cron.php

There is no telegram_api_helpers.php dependency. Back up current files and deploy these as one release during a maintenance window. Updating bootstrap before telegram.php would call a loader absent from the old runtime.

## Editor and reference files

- dashboard.php
- appview.php
- assets/js/telegram-api-catalog.js
- assets/js/telegram-helper-catalog.js
- docs/articles.json
- docs/assets/js/docs-content.js
- docs/telegram-helpers.md
- docs/docs.md
- docs/llms.txt
- docs/llms-full.txt
- llms.txt
- llms-full.txt

For a separate docs subdomain, map docs/ paths into that subdomain's document root.

All three example index.php files under examples/ have been updated to call the loader. Upload the chosen example only to its test bot.

## Verified locally

- Hosted child bootstrap leaves tg_send/tg_request and generated wrappers absent until opt-in.
- Calling the loader registers all 193 wrappers; repeated loading is safe.
- All wrapper routing tests and strict-ID/keyboard/callback regression tests pass.
- Platform gateway notifications use the internal transport and do not require a bot to opt in.

These are local checks. Run the live test bot and verify dashboard/cron behavior after server deployment. No all-method live or speed claim is made.
