# Telegram Helper Loading, PHP & Cron

> Explicit tg_all_fun loading, standalone PHP, hosted cron and migration.

**Category:** Getting Started  
**URL:** https://docs.botlify.cloud/tg-runtime-loading  
**Platform:** Botlify Cloud (https://botlify.cloud)  

---

## Which runtime are you using?

ExecutionNormal PHPTelegram helpersBotlify hosted webhookNo loader neededCall tg_all_fun() firstBotlify scheduled child cronNo loader neededCall tg_all_fun() firstDirect CLI: php script.phpRuns normallyNo Botlify runtime automatically providedBotlify platform dashboard/master cronPlatform bootstrapPlatform loads its own helpers

A scheduler entry is not the same as a PHP runtime. A cPanel cron that launches Botlify's master cron uses platform scheduling; a cPanel cron that directly launches your standalone PHP script does not automatically provide tg_all_fun().

## Normal PHP cron

```php

```

Schedule this file through the Botlify Files/Cron interface. It also works as standalone PHP, subject to folder permissions. No Telegram request is made.

## Hosted cron using Telegram helpers

```php

```

Call the loader before the first helper use on every request or cron execution. It registers the suite once per request; calling it again is safe. Your active hosted-bot credentials are resolved by the shared runtime. Missing or invalid credentials still cause API failures.

## Hosted webhook

```php

```

## Migrate existing helper bots

Before deploying the opt-in runtime, add the following compatibility line to every helper-based bot and child cron entrypoint. It supports both the old eager-loading runtime and the new runtime. Ordinary PHP/cURL bots do not need it.

```php
// Add before the first helper call, after declare(strict_types=1).
if (function_exists('tg_all_fun')) {
    tg_all_fun();
}
```

Deploy includes/telegram.php, includes/bootstrap.php, webhook.php and cron.php together. Updating bootstrap first against an old telegram.php can call a missing loader. Back up the existing release and use a maintenance window. Do not add platform include paths to hosted bot code. After migration, new bots can simply call tg_all_fun();.

## Common failures

- Undefined tg_send/tg_request: load the helpers before use.

- Undefined tg_all_fun: the new runtime is not deployed, or the script runs outside Botlify's hosted runtime.

- Strict-types declaration error: keep declare(strict_types=1) before the loader and all executable code.

- Cannot redeclare a helper: do not combine custom functions using the same names with the native suite.

- Telegram ok=false: inspect description and response parameters; loading cannot fix permissions, rate limits or invalid inputs.

## What is and is not loaded

The public helper suite is registered on opt-in in hosted webhook and isolated child-cron requests. Internal platform transport and the loader remain available. The containing PHP file can still be compiled; this is not a zero-parsing-overhead or guaranteed speed claim. Platform pages load helpers for platform operations.

[Complete native helper reference](/tg-native-helpers) · [Deployment checklist](/telegram-loader-deployment.md)
