ThinkAdmin Documentation

repository·v6·Indexed 24 days ago

https://github.com/zoujingli/thinkadmin

A modern, high-performance backend management system built on ThinkPHP 6 & 8. It features a Composer-based plugin micro-architecture, annotation-driven RBAC, a multi-process asynchronous task system, and a unified file storage engine supporting drivers like Local, Alist, Qiniu, Alibaba Cloud OSS, and Tencent Cloud COS. Designed for rapid development of enterprise-level systems such as CRM, ERP, and SaaS platforms.

Tokens
5.1K
Snippets
7
Records
30
Agent score
81%

What's inside ThinkAdmin

  1. Overview of the Moono-lisa CKEditor 4 skin

    v6

    Moono-lisa is a monochromatic skin for CKEditor 4 (default since version 4.6.0). It provides a modern, flat, and minimalistic aesthetic suitable for modern web designs.

    Key features include:

    • Chameleon feature: Allows for brightness adjustments.
    • High-contrast compatibility: Supports accessibility requirements.
    • SVG Graphics: Uses SVG for high-quality icon rendering.
  2. How Annotation-driven RBAC works

    v6

    The system implements a Role-Based Access Control (RBAC) model driven by PHP annotations (docblocks) within controllers.

    1. Automatic Generation: By adding annotations to controller methods, the system automatically generates permission nodes.
    2. Granular Control: Permissions can be controlled down to the specific button level.
    3. Dynamic Menus: The admin interface dynamically renders menus based on the user's assigned permissions.
    4. Audit Logs: All user actions are recorded for security auditing.
  3. How the Asynchronous Task System works

    v6

    ThinkAdmin features a multi-process asynchronous task system designed for handling long-running or heavy data tasks.

    • Multi-process Architecture: It can spawn multiple independent PHP processes to run tasks concurrently.
    • Monitoring: A background process scans the task data table every 0.5 seconds to execute pending tasks.
    • Process Management: Supports commands like START, STOP, QUERY, and LISTEN to manage task workers.
    • Cross-platform: Compatible with both Windows and Linux environments.
  4. Manage permissions and menus with annotations

    v6

    You can automatically generate functional nodes and permission configurations by adding annotations to your controller methods.

    Supported annotations:

    • @auth true: Requires authentication/permission verification.
    • @menu true: Automatically adds the method to the system menu.
    • @login true: Requires the user to be logged in.
    /**
     * User List
     * @auth true
     * @menu true
     */
    public function index()
    {
        // Method content
    }
  5. How the Plugin Architecture works

    v6
    ThinkAdmin uses a Composer-based plugin micro-architecture. Instead of modifying the core system, all business logic and features should be encapsulated into independent plugin packages. This allows for a 'hot-swappable' ecosystem where modules can be installed, updated, or removed via Composer without affecting the core framework.
  6. Install ThinkAdmin via Composer

    v6
    To create a new ThinkAdmin project, use the composer create-project command. Note that this command must be executed in a directory with an English name. By default, it only installs the admin and static modules.
  7. System Requirements for ThinkAdmin

    v6

    Ensure your environment meets the following minimum and recommended specifications:

    Base Requirements

    • PHP: 7.1+ (Recommended: 8.0+)
    • Composer: 2.0+ (Recommended: 2.5+)
    • Database: SQLite 3 (Minimum) or MySQL 8.0+ (Recommended)
    • Memory: 128MB (Minimum) or 512MB+ (Recommended)

    Required PHP Extensions

    • gd (Image processing)
    • mbstring (Multibyte string handling)
    • openssl (Encryption)
    • pdo (Database abstraction)
    • curl (HTTP client)
    • fileinfo (File type detection)
    • json (JSON processing)
    • zip (Compression)
  8. Install and manage ThinkAdmin plugins via Composer

    v6

    ThinkAdmin uses Composer for plugin management. You can install free or paid plugins by running the appropriate composer require command. To remove a plugin, use composer remove.

    Note: Uninstalling a plugin via Composer does not automatically delete its associated database tables; these must be cleaned up manually.

  9. Customize ThinkAdmin themes and styles

    v6

    You can customize the appearance of the ThinkAdmin interface through three primary methods:

    1. CSS: Add custom styles in the public/static/css/ directory.
    2. System Parameters: Configure theme-related settings directly in the admin dashboard.
    3. Templates: Modify the view files located in app/admin/view/.
  10. Create new controllers and add permission control

    v6

    To extend the admin functionality, you can create custom controllers and apply security constraints using annotations.

    1. Controller Creation: Create a new file in the app/admin/controller/ directory. Your class must extend think\admin\Controller.
    2. Permission Control: Add specific annotations to your controller methods to enforce security:
      • @auth true: Requires authentication.
      • @menu true: Requires menu permission.
      • @login true: Requires login status.
  11. Develop custom plugins using the Plugin class

    v6

    ThinkAdmin requires all business logic to be implemented via its plugin architecture. To create a plugin, extend the think\admin\Plugin class and implement the install() and uninstall() methods to handle database tables and menus.

    Plugins are managed via Composer, supporting hot-swapping and online upgrades.

    <?php
    namespace app\plugin\example;
    
    use think\admin\Plugin;
    
    class ExamplePlugin extends Plugin
    {
        public function install()
        {
            // Operations during plugin installation
            $this->createTables();
            $this->createMenus();
        }
        
        public function uninstall()
        {
            // Operations during plugin uninstallation
            $this->dropTables();
            $this->removeMenus();
        }
    }
  12. Enable Production Mode for performance optimization

    v6

    To optimize system performance, you can switch the application to production mode. This typically enables caching and other optimizations.

    Navigate to System Management (系统管理)System Parameter Configuration (系统参数配置), find the "Running Mode" (运行模式) option, select "Production Mode" (生产模式), save, and clear the system cache.