zjkal/webman-skill

webman

- Expert skill for the webman framework (a long-lived, in-memory PHP framework based on workerman).

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/zjkal/webman-skill --skill webman

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

webman Framework Development

webman is a high-performance, long-lived in-memory PHP framework built on workerman. Unlike PHP-FPM (bootstrap per request, tear down after response), correct webman code starts from understanding the resident-process model.

Core Mental Model: Resident Memory

After startup, a worker stays in memory and handles thousands of requests. Hard rules that follow:

  1. Never `exit` / `die`: they kill the whole worker and drop every

connection on that process.

  1. Static properties / globals survive across requests: data written by the

previous request can "leak" into the next. Keep request-scoped data in local variables, $request attributes, or support\Context under coroutines.

  1. Singletons are shared across requests: do not store request state on

singletons; array properties that only grow are memory leaks.

  1. Code changes need reload/restart (php start.php reload). In debug

mode, status / connections help diagnose issues.

  1. Controllers are new per request by default (controller_reuse => false

in config/app.php). If reuse is enabled, controller properties also survive across requests.

Project Layout

├── app/                  # Application code
│   ├── controller/       # Controllers (optional; MVC or DDD as you prefer)
│   ├── model/            # Models
│   ├── middleware/       # Middleware
│   └── functions.php     # Custom helpers
├── config/               # All configuration
│   ├── route.php         # Routes
│   ├── process.php       # Process definitions (HTTP, custom, timers)
│   ├── middleware.php    # Middleware registration
│   ├── database.php      # Database (illuminate/database)
│   ├── redis.php         # Redis
│   └── plugin/           # Plugin config
├── plugin/               # Application plugins
├── public/               # Static assets (only web-accessible directory)
├── process/              # Custom process classes
├── support/              # Framework bridge code
└── start.php             # Entry point

Common Commands

bash
composer create-project workerman/webman   # create project

# Linux / macOS
php start.php start        # foreground (debug)
php start.php start -d     # daemon (production)
php start.php reload       # graceful reload (code updates, keep connections)
php start.php restart -d   # full restart (required after process.php, Timer, or resident data changes)
php start.php stop
php start.php status       # process memory, request counts
php start.php connections  # connection info

# Windows (no daemon / reload)
php windows.php

reload vs restart: reload only reloads app code (app/ and most of config/). Changes to config/process.php or timers/connections already created in onWorkerStart are not reloaded — use restart.

Coding Conventions

  • PHP >= 8.0 (webman v2 requires 8.1+); always declare(strict_types=1).
  • Controller signatures: public function action(Request $request): Response,

with support\Request.

  • Return Webman\Http\Response via helpers (response(), json(), view(),

redirect(), …). Do not echo.

  • Prefer illuminate/database (Db::table() / Eloquent models extending

support\Model).

  • Read config with config('app.debug'); never include config files.
  • Log with support\Log (Log::info() / Log::channel('xx')->info()), not

error_log or echo.

Do / Don't Cheatsheet

Don'tDo
exit() / die() to end a requestreturn response(...) or throw
$_GET / $_POST / $_SESSION$request->get() / $request->post() / $request->session()
header() / setcookie()$response->header() / $response->cookie()
Unbounded static arraysBounded cache (LRU) or Redis
Request data on singletonsLocals / support\Context (coroutines)
Timers created per request in app codeCustom process in config/process.php
Static vars for request state under coroutinessupport\Context::set() / get()

References (read on demand)

관련 작업