Framework12 min readNot archived on GitHub

ThinkPHP: an MVC PHP framework, based on its official repository

A source-limited guide guide to ThinkPHP 8: what the framework is, how to install the skeleton with Composer, what the README says, and what remains unknown.

PHP compatibility and project lifecycle

Source README states ThinkPHP 8 requires PHP 8.0+ and think-orm 3.0+. PHP 8.4 and PHP 8.5 compatibility, current release number and support status are not stated and are unknown.

Official sources checked 2026-10-22. Browser lessons on this site run PHP 8.5.

What this project is

ThinkPHP is a PHP framework. The official repository, top-think/framework, describes itself as "ThinkPHP Framework" and lists the topics framework, orm, route and template. The task focus is its MVC design, but the supplied README does not walk through MVC. This guide therefore avoids describing controller, model or view code that the source does not show.

Classification

ThinkPHP is a framework, meaning a library layer that runs on top of PHP. It is not:

  • a PHP runtime or interpreter. PHP itself, the core language and engine, is a separate project that you install first.
  • a CMS. A CMS such as Drupal is a complete content product built on PHP. A framework gives you structure and components for building your own application.
  • an async library or a persistent-worker server. Nothing in the supplied source says ThinkPHP bundles one.

The repository also holds only the framework package. The README installs an application skeleton with a different Composer package, topthink/think. Treat the skeleton as the starting point for an application and the framework as a dependency of it.

Architecture and version facts from the source

The README is mostly in Chinese. It states these points for ThinkPHP 8:

  • It is rebuilt on PHP 8.0 or newer, and the runtime requirement is PHP 8.0+.
  • It upgrades its PSR dependencies.
  • It depends on think-orm 3.0 or newer.
  • It introduces think-dumper, which supports remote debugging.
  • It claims seamless upgrade from 6.0 and 6.1.
  • It follows PSR-2 naming conventions and PSR-4 autoloading.

The repository page shows an 8.x branch, a src directory, a tests directory, a composer.json, a phpunit.xml.dist and a php-cs-fixer configuration. The topics suggest built-in routing, an ORM and a template layer. The supplied source does not document how they work.

Execution model

The supplied source does not describe the execution model. It documents only a development command, php think run, which serves the application at http://localhost:8000. It does not say what server that command uses or whether its host can be configured.

It helps to know the two common PHP lifetimes:

  • Classic request lifetime: each HTTP request starts from a clean PHP state, runs the application, then discards objects, static properties and globals. Under this model most state leakage cannot happen, because PHP resets everything for the next request.
  • Persistent worker: one PHP process boots the application once and handles many requests. Startup is amortised, but memory is shared between requests. Swoole and Open Swoole are two separate projects of this kind, and neither appears in the supplied source.

If you ever run a framework in a persistent worker, which is outside what this source covers, plan for state leakage. Static properties, singletons, service containers, authenticated user objects, request-scoped caches, open database transactions and unbounded arrays can all carry data from one request to the next. A user's data could then appear in another user's response, or memory could grow until the worker is killed. Cleanup means resetting or rebuilding per-request state after every request, closing or revalidating connections, bounding caches, and recycling workers on a schedule. Check the adapter's own documentation for how it does this. This source does not establish whether ThinkPHP supports persistent workers, so treat that as unknown.

Practical use cases

The source supports only a general statement: ThinkPHP is for building PHP web applications with a routing layer, an ORM and templates, as its topics suggest. It names no case studies or benchmarks, and this guide makes no speed claims. Reasonable learning uses are reading an MVC-style framework in the PHP 8 era and comparing its conventions with other frameworks. Evaluate any production use against the official manual, which the README links but the supplied source does not reproduce.

Installation approach

The README gives three commands. The first creates a project in a directory called tp. The second starts the development server from inside it. The third updates the framework later:

  • composer create-project topthink/think tp
  • cd tp, then php think run
  • composer update topthink/framework

The example below follows this path and adds a small PHP script that reads the generated manifest. It uses no ThinkPHP APIs.

PHP 8.4 is the learning track, and PHP 8.5 is planned. The README states only a PHP 8.0+ requirement. Whether ThinkPHP 8 works on PHP 8.4 or PHP 8.5 is unknown from this source, so verify on a throwaway project before relying on it. Run the example in a local terminal, because it needs Composer and network access to fetch packages, so it is not a browser exercise.

Strengths

  • The README gives a short install path through Composer.
  • It targets modern PHP (8.0+) and PSR-4 autoloading.
  • The repository has a tests directory and a PHPUnit configuration file.
  • It ships with ORM, routing and template topics in one ecosystem.
  • It states an Apache 2 license, and a LICENSE.txt is present.
  • Contributions are accepted by pull request or issue.

Limitations and unknowns

  • The README is in Chinese. Learners who do not read it will rely on translation of the documentation.
  • The supplied source does not state the current release number, support or end-of-life policy, PHP 8.4 or 8.5 compatibility, performance, or a production deployment recipe. Lifecycle is therefore recorded as unknown.
  • Trademark and copyright are held by a company, and the README notes that third-party code carries separate notices. Read LICENSE.txt before reuse.
  • The README mentions sponsorship, an AI assistant and cloud services. This guide does not evaluate them and states no prices.

Deployment

The supplied source gives no production deployment instructions. Do not treat php think run as a production server, since the source does not describe it as one. Keep it on your own machine and confirm the address it listens on. Because the source documents no host option, do not publish its port to a network. If you later put a web server in front of PHP, never expose FastCGI publicly, and follow the official manual for the document root and rewrite rules. Keep secrets out of version control.

Links

The only supplied official resource is the top-think/framework repository on GitHub. Start with its README, contributing guide and license file.

Practical examples

These examples have not been run in a live environment yet. Commands and versions follow the official documentation linked on this page; check them before relying on them, and report a problem if one does not work.

Install the ThinkPHP skeleton and inspect it with a PHP script

Installs the official skeleton with the documented Composer command, then runs a small standalone PHP script from the parent directory to confirm the expected files exist and print the requirements the generated manifest declares. It uses no ThinkPHP APIs, so no framework code is invented. Finally it starts the documented development server.

check-skeleton.php

<?php

declare(strict_types=1);

// Run from the directory that contains the "tp" folder created by Composer.
$root = __DIR__ . '/tp';

if (PHP_VERSION_ID < 80000) {
    fwrite(STDERR, "ThinkPHP 8 README states PHP 8.0+ is required.\n");
    exit(1);
}

$required = [
    'composer.json',
    'vendor/topthink/framework/composer.json',
];

foreach ($required as $relative) {
    if (!is_file($root . '/' . $relative)) {
        fwrite(STDERR, "Missing expected file: tp/{$relative}\n");
        exit(1);
    }
}

$manifest = json_decode(
    (string) file_get_contents($root . '/composer.json'),
    true,
    512,
    JSON_THROW_ON_ERROR
);

echo 'PHP in use: ' . PHP_VERSION . PHP_EOL;
echo "Requirements declared by tp/composer.json:\n";

foreach (($manifest['require'] ?? []) as $package => $constraint) {
    echo "  {$package} {$constraint}\n";
}

echo "Skeleton looks present. PHP 8.4 compatibility is not confirmed by the source.\n";

Install and run

composer create-project topthink/think tp
php check-skeleton.php
cd tp
php think run

Expected behavior

Composer creates a tp directory containing the skeleton and its dependencies. The check script prints the PHP version and the packages from tp/composer.json, then reports that the skeleton looks present. After php think run, the README says the application is reachable at http://localhost:8000 in a browser.

Needs Composer, PHP 8.0 or newer, and network access, so it is not a browser exercise. The skeleton layout is not described in the supplied source, so the script checks only the manifest and the framework package. The dev server's host option is undocumented in the source, so keep the port on your local machine only. PHP 8.4 behavior is unverified.