3.8 KiB
3.8 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
FastAdmin 1.6.x admin panel built on ThinkPHP 5.x (forked from gitee.com/fastadminnet/framework.git). The project is a Macau lottery (澳门六合彩) data tracking application named "amlhc".
- PHP >= 7.4.0, Apache-2.0 license
- Database: MySQL with
fa_table prefix, utf8mb4 charset - Frontend: RequireJS + Bootstrap 3.4 + AdminLTE skin
Key Directories
| Path | Purpose |
|---|---|
application/admin/ |
Admin backend — controllers, models, views, validates, lang |
application/index/ |
Public-facing frontend |
application/api/ |
REST API endpoints |
application/common/ |
Shared base controllers, models, libraries, global helpers |
application/extra/ |
Extra config: site.php, upload.php, queue.php, addons.php |
public/ |
Web root — entry point index.php, static assets in assets/ |
addons/ |
Plugin directory (currently command addon installed) |
sql/ |
SQL migration/DDL files |
thinkphp/ |
Vendored ThinkPHP 5.x framework |
Config Loading Chain
All files under application/ are merged by ThinkPHP:
config.php— main config (debug, modules, URL, template, session, cookie, FastAdmin settings)database.php— DB connection (reads from.env)extra/*.php— site, upload, queue, addons configroute.php— URL routing (currently empty)
Environment variables are loaded from .env via think\Env.
Admin Module Architecture
All admin controllers extend app\common\controller\Backend, which provides:
- RBAC auth via
app\admin\library\Auth(salt double-MD5, session + cookie) - CRUD base operations (index/add/edit/del/multi) via
app\admin\library\traits\Backend - Search/filtering, SelectPage, import/export
- Layout templating via
application/admin/view/layout/default.html
Standard controller pattern: Each admin controller maps to a model + view directory + validate + lang file:
controller/X.php → model/X.php → view/x/ → validate/X.php → lang/zh-cn/x.php
Custom Domain Code (Lottery)
| File | Purpose |
|---|---|
application/admin/controller/History.php |
Lottery history admin |
application/admin/model/History.php |
fa_history model |
application/admin/controller/Num.php |
fa_num color mapping API (getColorMap) |
application/admin/model/Num.php |
fa_num model |
application/index/controller/Index.php |
Scrapes lottery data from external API |
Frontend Build System
Grunt (Gruntfile.js) is the build tool:
grunt deploy— copy npm packages topublic/assets/libs/grunt backend:js/grunt frontend:js— RequireJS optimizer for JSgrunt backend:css/grunt frontend:css— Less → CSS compilation
JS uses RequireJS with separate entry points: require-backend.js and require-frontend.js.
Common Development Commands
Install dependencies
composer install
npm install
grunt deploy # copy npm deps to public/assets/libs/
grunt # build all JS/CSS
Run dev server
php -S 127.0.0.1:8000 -t public public/router.php
Generate CRUD scaffolding (built-in)
php think crud --table=fa_xxx --controller=xxx --model=xxx
Generate menu for admin controller
php think menu --controller=xxx/xxx
Run tests
php think unit
Important Notes
- Admin entry is
public/index.php(the admin module is accessed via URL routing, not a separateadmin.php) - All database queries use ThinkPHP's query builder (
Db::name('table')) or models - Language files use key-value pairs; keys are English labels (e.g.,
'Num1' => '号码1') - The
.envfile contains actual credentials — never commit it - Runtime cache lives in
runtime/— clear it when config changes don't take effect