Configs2026年5月19日·1 分钟阅读

ThinkPHP — Lightweight Rapid Development PHP Framework

ThinkPHP is a lightweight PHP framework focused on rapid application development with convention-over-configuration design, widely adopted in the Chinese PHP development community.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
ThinkPHP Overview
通用 CLI 安装命令
npx tokrepo install 3e6c431a-53c1-11f1-9bc6-00163e2b0d79

Introduction

ThinkPHP is a PHP framework with over two decades of development history, designed for fast web application development with a low learning curve. It follows convention-over-configuration principles and provides a complete toolkit for building web applications and APIs.

What ThinkPHP Does

  • Provides an MVC architecture with automatic routing and URL rewriting
  • Includes an ORM with query builder and model relationships
  • Offers built-in template engine with tag library support
  • Supports middleware, events, and service providers
  • Provides CLI tools for code generation and task scheduling

Architecture Overview

ThinkPHP uses a multi-application architecture where a single installation can host multiple independent applications. The request lifecycle flows through middleware stacks, route matching, controller dispatch, and response rendering. The framework supports both traditional request-response and command-line application modes, with a service container managing dependency injection.

Self-Hosting & Configuration

  • Install via Composer with composer create-project topthink/think
  • Configure database and app settings in the config/ directory
  • Use environment files (.env) for deployment-specific values
  • Run the built-in development server with php think run
  • Deploy with Nginx or Apache and PHP-FPM in production

Key Features

  • Multi-application support within a single project installation
  • Fluent query builder with chainable database operations
  • Built-in caching with drivers for Redis, Memcached, and file
  • Route annotations and automatic controller-based routing
  • Command-line toolkit for migrations, seeds, and custom commands

Comparison with Similar Tools

  • Laravel — feature-rich with larger ecosystem; ThinkPHP offers a simpler learning curve for rapid development
  • Yii2 — similar full-stack approach; ThinkPHP has stronger adoption in the Chinese PHP community
  • Symfony — component-based and enterprise-grade; ThinkPHP prioritizes speed of development
  • CodeIgniter — lightweight and simple; ThinkPHP provides more built-in features like multi-app support
  • Slim — micro framework for APIs; ThinkPHP is a full-stack framework with views and ORM

FAQ

Q: Is ThinkPHP documentation available in English? A: The primary documentation is in Chinese, though community translations and the codebase itself use English for class and method names.

Q: What PHP version does ThinkPHP require? A: ThinkPHP 8.x requires PHP 8.0 or higher.

Q: Can ThinkPHP be used for API development? A: Yes. ThinkPHP supports RESTful routing, JSON responses, and API-specific middleware out of the box.

Q: How does ThinkPHP handle database migrations? A: ThinkPHP includes a migration system accessible via php think migrate:run with support for creating and rolling back schema changes.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。