定制 nutgram/starter-kit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nutgram/starter-kit

最新稳定版本:1.0.0

Composer 安装命令:

composer require nutgram/starter-kit

包简介

Starter kit for Nutgram

README 文档

README

This is a lightweight starter kit for building Telegram bots using the Nutgram PHP framework.

Features

  • Nutgram Framework: High-performance Telegram Bot framework.
  • Environment Configuration: Easy management of environment variables with phpdotenv.
  • Caching: PSR-16 cache support out of the box.
  • Testing: Ready-to-use testing environment with Pest.
  • Structured: Organized directory structure for Commands and Conversations.

Requirements

  • PHP 8.2 or higher
  • Composer

Usage

  1. Create the project:

    composer create-project nutgram/starter-kit my-telegram-bot
    cd my-telegram-bot
  2. Install dependencies:

    composer install
  3. Configure the environment: Copy the example environment file and add your Telegram Bot token:

    cp .env.example .env

    Edit .env and set your TOKEN:

    TOKEN=your_telegram_bot_token_here
    WEBHOOK_TOKEN=random_webhook_token

Usage

Running the Bot

Polling Mode

To run the bot in polling mode (ideal for development), execute:

php bot.php

Webhook Mode

To use the webhook mode, point your web server's document root to the public/ directory. Ensure your server is accessible via HTTPS.

Finally, you need to register your webhook URL with Telegram. You can do this by making an HTTP request (e.g., using curl) to the following address:

curl "https://api.telegram.org/botTOKEN/setWebhook?secret_token=WEBHOOK_TOKEN&url=https://YOUR_DOMAIN"

Replace:

  • TOKEN with the same value you used in your .env file
  • https://YOUR_DOMAIN with your actual webhook URL.
  • WEBHOOK_TOKEN with the same value you used in your .env file

Project Structure

  • src/routes.php: Register your commands, conversations, and handlers.
  • src/bootstrap.php: Bot initialization and configuration.
  • public/index.php: Entry point for both polling and webhook.
  • tests/: Feature and unit tests.

Running Tests

You can run the tests using Pest:

composer test

License

This project is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固