Download the PHP package hojjatjh/bot-builder without Composer

On this page you can find all versions of the php package hojjatjh/bot-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bot-builder

🤖 BotBuilder

A modern, zero-dependency PHP scaffolding engine that builds ready-to-run projects (like Telegram bots) from reusable templates.

Latest Version Total Downloads PHP Version

English | فارسی


Table of Contents

Why BotBuilder?

Building many similar projects by hand is repetitive and error-prone. BotBuilder lets you keep a single base template and generate as many customized copies as you want — each one filled with its own values. Perfect for spinning up new Telegram bots, micro-services, or any boilerplate project in seconds, while your original template stays untouched and reusable forever.

Features

How It Works

BotBuilder reads a base/template directory, replaces every {{KEY}} token with the values you provide, and writes the result into a new output directory — leaving the original template untouched.

Requirements

Installation

Quick Start

Creating a Template

A template is nothing more than a normal folder of files. Wherever you want a value to be filled in later, you write a placeholder like {{BOT_NAME}}. That's the whole idea — there is nothing complicated to learn.

💡 Important: BotBuilder does not care about file names, and it is not limited to config.php. It scans every file in the template, so your placeholders work in any file you like — config.php, server-key.php, .env, README.md, anything.

Step 1 — Put placeholders in your files

Your config file can have any name. Here it is called config.php:

Step 2 — Placeholders also work in file & folder names

A file literally named {{BOT_NAME}}.php becomes MyCoolBot.php after building. The same works for folders, e.g. handlers/{{BOT_NAME}}/.

Step 3 — Use as many files as you want (a real example)

A template can hold any number of files. Here it has two: config.php and server-key.php.

config.php

server-key.php

A single build() call fills in both files at once:

Files without any placeholder are simply copied as-is, so you can freely mix static and templated files (PHP, JSON, .env, Markdown, images — anything).

Usage

Defining config (required & defaults)

If a required value is missing, a BotBuilderException is thrown before anything is written to disk — so you never end up with a half-generated project.

Overwriting an existing target

Without overwrite: true, building into a directory that already exists throws an exception (this protects you from accidentally clobbering previous work).

Using the lower-level pieces

The BotBuilder facade is optional. You can compose the parts directly:

Custom delimiters

API Reference

BotBuilder (facade)

Method Description
__construct(string $templatePath) Point at the base template folder.
define(string $key, ?string $default = null, bool $required = false): self Register an expected placeholder.
build(string $target, array $values, bool $overwrite = false): array Validate values and generate the project. Returns the generated file paths.

BotGenerator

Method Description
__construct(Template $template, PlaceholderReplacer $replacer = new PlaceholderReplacer()) Build from a template with an optional custom replacer.
generate(string $target, array $values, bool $overwrite = false): array Generate files (content + names) into the target directory.

Template

Method Description
__construct(string $path) Wrap a base directory (must exist).
path(): string The template root path.
files(): array All files as relative paths (recursive).
read(string $relativePath): string Read a single file's content.

Config

Method Description
define(string $key, ?string $default = null, bool $required = false): self Declare an expected placeholder.
resolve(array $values): array Merge given values with defaults and validate required keys.

PlaceholderReplacer

Method Description
__construct(string $open = '{{', string $close = '}}') Configure the delimiters.
replace(string $content, array $values): string Replace known tokens (unknown ones are left untouched).
placeholders(string $content): array List the unique tokens found in a string.

Full Example: Telegram Bot

base/telegram-bot/config.php

base/telegram-bot/bot.php

Generate it:

Now run your brand-new bot:

Testing

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.

License

Released under the MIT License. See LICENSE for details.


📖 راهنمای فارسی

**BotBuilder** یک موتور scaffolding مدرن و بدون هیچ وابستگی برای PHP است که پروژه‌های آماده‌ی اجرا (مثل ربات‌های تلگرام) را از روی قالب‌های قابل‌استفاده‌ی مجدد می‌سازد. ### فهرست - چرا BotBuilder؟ - ویژگی‌ها - چطور کار می‌کند - پیش‌نیازها - نصب - شروع سریع - ساخت یک قالب - استفاده - مرجع API - مثال کامل: ربات تلگرام - تست - مشارکت - لایسنس ### چرا BotBuilder؟ ساختن دستیِ چندین پروژه‌ی مشابه، تکراری و مستعد خطاست. با BotBuilder فقط یک **قالب پایه (base)** نگه می‌داری و هر تعداد که خواستی نسخه‌ی سفارشی‌شده از رویش می‌سازی — هرکدام با مقادیر مخصوص خودش. عالی برای ساختِ ربات‌های تلگرام جدید یا هر پروژه‌ی boilerplate در چند ثانیه، درحالی‌که قالب اصلی‌ات دست‌نخورده و برای همیشه قابل استفاده می‌ماند. ### ویژگی‌ها - 🧩 **scaffolding مبتنی بر قالب** — کل پروژه از روی یک پوشه‌ی base ساخته می‌شود. - 🔖 **جای‌گزینی `{{PLACEHOLDER}}`** هم در **محتوای فایل‌ها** و هم در **نام فایل/پوشه‌ها**. - 🗂 **روی هر فایلی کار می‌کند** — فقط `config.php` نیست؛ همه‌ی فایل‌های قالب اسکن می‌شوند. - 🧵 **چند فایل هم‌زمان** — در یک build هم `config.php` و هم `server-key.php` و بیشتر را پر می‌کند. - 🌳 **پوشه‌های تودرتو** به‌صورت بازگشتی پشتیبانی می‌شوند. - ✅ **مقادیر اجباری و پیش‌فرض** با اعتبارسنجی داخلی. - ♻️ **قالب فقط‌خواندنی** — قالب هیچ‌وقت تغییر نمی‌کند و بی‌نهایت بار قابل استفاده است. - 🪶 **بدون هیچ وابستگی** — فقط فایل‌سیستم، کاملاً تست‌شده. - ⚙️ **جداکننده‌های قابل تنظیم** (پیش‌فرض `{{ }}`). ### چطور کار می‌کند BotBuilder یک **پوشه‌ی قالب** را می‌خواند، همه‌ی `{{KEY}}`ها را با مقادیر تو جایگزین می‌کند و نتیجه را در یک **پوشه‌ی خروجی جدید** می‌نویسد — بدون اینکه به قالب اصلی دست بزند.
### پیش‌نیازها - PHP نسخه‌ی 8.1 یا بالاتر - افزونه‌ی ext-json ### نصب
### شروع سریع
### ساخت یک قالب یک **قالب** چیزی نیست جز یک پوشه‌ی معمولی از فایل‌ها. هر جا خواستی بعداً یک مقدار جایگزین شود، یک placeholder مثل `{{BOT_NAME}}` می‌نویسی. کل ایده همین است — هیچ چیز پیچیده‌ای برای یادگرفتن نیست. > 💡 **مهم:** BotBuilder به اسم فایل‌ها کاری ندارد و **فقط محدود به `config.php` نیست**. همه‌ی فایل‌های قالب را می‌خواند، پس placeholderهایت در هر فایلی کار می‌کنند — `config.php`، `server-key.php`، `.env` یا هر چیزی. **قدم ۱ — placeholder در فایل‌هایت بگذار** فایل کانفیگت می‌تواند **هر اسمی** داشته باشد. اینجا اسمش `config.php` است:
**قدم ۲ — placeholder در نام فایل و پوشه هم کار می‌کند** فایلی به اسمِ `{{BOT_NAME}}.php` بعد از ساخت می‌شود `MyCoolBot.php`. برای پوشه‌ها هم همین‌طور، مثل `handlers/{{BOT_NAME}}/`. **قدم ۳ — هر تعداد فایل که خواستی (یک مثال واقعی)** یک قالب می‌تواند **هر تعداد فایل** داشته باشد. اینجا دو فایل دارد: `config.php` **و** `server-key.php`. فایل `config.php`:
فایل `server-key.php`:
فقط **یک** فراخوانی `build()` هر **دو** فایل را یکجا پر می‌کند:
فایل‌های **بدون** placeholder همان‌طور که هستند کپی می‌شوند، پس می‌توانی فایل‌های ثابت و قالبی را آزادانه کنار هم بگذاری (PHP، JSON، `.env`، Markdown، تصویر و هر چیز دیگر). ### استفاده **تعریف مقادیر (اجباری و پیش‌فرض):**
اگر یک مقدار اجباری داده نشود، **پیش از** نوشتن هر فایلی یک `BotBuilderException` پرتاب می‌شود — پس هیچ‌وقت پروژه‌ی نصفه‌کاره تولید نمی‌شود. **بازنویسی مقصد موجود:**
بدون `overwrite: true`، ساختن در پوشه‌ای که از قبل وجود دارد خطا می‌دهد (این جلوی خراب‌کردن کارِ قبلی‌ات را می‌گیرد). **استفاده از اجزای سطح‌پایین:** نمای `BotBuilder` اختیاری است؛ می‌توانی مستقیم از اجزا استفاده کنی:
**جداکننده‌های سفارشی:**
### مرجع API
**`BotBuilder` (facade)** | Method | Description | |--------|-------------| | `__construct(string $templatePath)` | Point at the base template folder. | | `define(string $key, ?string $default = null, bool $required = false): self` | Register an expected placeholder. | | `build(string $target, array $values, bool $overwrite = false): array` | Validate values and generate the project. Returns the generated file paths. | **`BotGenerator`** | Method | Description | |--------|-------------| | `generate(string $target, array $values, bool $overwrite = false): array` | Generate files (content + names) into the target directory. | **`Template`** | Method | Description | |--------|-------------| | `path(): string` | The template root path. | | `files(): array` | All files as relative paths (recursive). | | `read(string $relativePath): string` | Read a single file's content. | **`Config`** | Method | Description | |--------|-------------| | `define(string $key, ?string $default = null, bool $required = false): self` | Declare an expected placeholder. | | `resolve(array $values): array` | Merge given values with defaults and validate required keys. | **`PlaceholderReplacer`** | Method | Description | |--------|-------------| | `replace(string $content, array $values): string` | Replace known tokens (unknown ones are left untouched). | | `placeholders(string $content): array` | List the unique tokens found in a string. |
### مثال کامل: ربات تلگرام **فایل `base/telegram-bot/config.php`**
**فایل `base/telegram-bot/bot.php`**
**ساختنش:**
حالا رباتِ تازه‌ساخته‌شده‌ات را اجرا کن:
### تست
### مشارکت از مشارکت استقبال می‌شود! توی [گیت‌هاب](https://github.com/hojjatjh/bot-builder) به‌راحتی issue باز کن یا pull request بفرست. ### لایسنس تحت **لایسنس MIT** منتشر شده است. برای جزئیات فایل [LICENSE](LICENSE) را ببین.

Made with ❤️ by hojjatjh


All versions of bot-builder with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hojjatjh/bot-builder contains the following files

Loading the files please wait ...