kabachello/codiware
Composer 安装命令:
composer require kabachello/codiware
包简介
Codiware Editor - PHP cloud IDE delivered as a single PSR-15 middleware.
README 文档
README
A self-contained, embeddable web IDE delivered as a single PSR-15 middleware plus a dependency-free SPA. Codiware is designed to be mounted under an arbitrary base path inside any PHP host application (e.g. the ExFace workbench) and operate on a configurable set of workspace folders.
Features
- File tree, multi-tab editor, save / rename / delete / upload / download
- Pluggable editor registry (textarea fallback included; Monaco, CodeMirror, Toast UI, etc. can be plugged in via npm-asset packages or custom JS)
- Git source-control panel (status, stage / unstage / discard, commit, amend,
push, branches, history) over the local
gitCLI - Workspace-wide search and search-and-replace with regex / case options
- In-IDE console with a deny-by-default allowlist + operator-curated presets
- Light/dark themes via CSS custom properties; per-locale translations
- All paths protected by a single
PathGuardthat rejects traversal, symlink escape, and matches configurable deny patterns (.env,*.key, …)
Requirements
- PHP 8.2+
- Composer
- Server Content-Security-Policies must include these:
font-src data: ; worker-src blob: ;
- Optional: a local
gitbinary for the source-control panel
Install
composer require axenox/codiware
The package depends on npm-asset/* packages for optional front-end editors.
The composer.json already enables Asset Packagist
so npm-asset/monaco-editor and friends can be installed alongside PHP
packages.
Mount in a host
use kabachello\Codiware\Middleware\CodiwareMiddleware; use kabachello\Codiware\Middleware\CodiwareConfig; use kabachello\Codiware\Middleware\UserContext; $middleware = new CodiwareMiddleware( config: CodiwareConfig::fromFile(__DIR__ . '/codiware.json'), responseFactory: $psr17, streamFactory: $psr17, logger: $psrLogger, userContext: new UserContext($user->getName(), $user->getEmail(), $user->getId()) );
CodiwareMiddleware implements Psr\Http\Server\MiddlewareInterface. Any
request whose URI path is not under the configured base path is delegated
unchanged to the next handler.
Workspace URL
GET {basePath}/repo/{workspacePath...} returns the SPA shell with a boot
payload describing the requested workspace, user, theme, locale, and enabled
extensions. All subsequent API calls go to other {basePath}/... routes.
Configuration
Defaults are shipped in config/defaults.config.json.
At runtime, CodiwareConfig behaves like ExFace config maps:
- keys are normalized to uppercase
- nested objects are flattened to dot keys (
CONSOLE.ENABLED) - arrays and arrays of objects stay as values (
CONSOLE.PRESETS)
See dev-server.config.json.example for a documented sample.
Typical host override patterns:
$config = CodiwareConfig::fromFile(__DIR__ . '/codiware.json') ->set('URL_TO_API', '/api/ide/codiware') ->merge([ 'THEME.DEFAULT' => 'dark', 'CONSOLE.TIMEOUT_SECONDS' => 120, ]);
Key options:
| Key | Purpose |
|---|---|
URL_TO_API |
URL prefix the middleware listens on (default /codiware). |
BASE_FOLDER |
Folder whose direct children are valid workspace aliases. |
ALLOWED_ROOTS |
Explicit [{alias, path, label}] list overriding BASE_FOLDER. |
DENY_PATTERNS |
fnmatch patterns rejected by PathGuard. |
MAX_UPLOAD_BYTES |
Per-file upload limit. |
GIT.BINARY |
Path to the git executable. |
CONSOLE.ALLOW_PATTERNS |
Regex allowlist for raw console commands. |
CONSOLE.PRESETS |
[{label, command}] shortcuts always allowed. |
THEME.DEFAULT |
light or dark. |
TRANSLATIONS.DEFAULT_LOCALE |
Initial UI locale. |
EXTENSIONS.ENABLED |
Identifiers of front-end extensions to load. |
Development server
composer install cp dev-server.config.json.example dev-server.config.json php -S localhost:8080 -t public public/dev-server.php
Open http://localhost:8080/codiware/repo/{workspace-alias}.
Extending the editor
The SPA exposes a small global API on window.Codiware:
window.Codiware.registerEditor({ id: 'my.editor', label: 'My editor', priority: 50, accepts: (entry) => /\.json$/i.test(entry.path), create: (host, ctx) => new MyEditor(host, ctx), });
Each editor implements load(content, meta), getContent(), isDirty(),
markClean(), destroy(), and an optional on('change'|'save-request', fn).
Adding a richer editor library (Monaco, CodeMirror 6, Toast UI):
composer require npm-asset/monaco-editor(or similar)- Drop a small JS module under
public/js/extensions/that imports the library from/{basePath}/assets/monaco-editor/...and callswindow.Codiware.registerEditor(...). - Add the extension id to
EXTENSIONS.ENABLEDin the config — the SPA boot payload exposes the list so your extension knows it is enabled.
Security model
- All filesystem paths flow through
kabachello\Codiware\Workspace\PathGuard, which resolves them viarealpath, rejects..traversal and any path that ends up outside the workspace root, and matches the configured deny patterns against both the relative path and the basename. - Uploaded ZIP archives are fully validated entry-by-entry (rejects absolute
paths,
../, and runs every resolved destination throughPathGuard) to prevent zip-slip. - Console commands are deny-by-default. A command runs only if it matches a
preset label or a configured regex in
CONSOLE.ALLOW_PATTERNS. - The middleware never trusts the host with raw paths: workspace selection
always goes through
WorkspaceResolverwhich validates againstALLOWED_ROOTS/BASE_FOLDERfirst.
License
MIT. See LICENSE.
kabachello/codiware 适用场景与选型建议
kabachello/codiware 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 131 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kabachello/codiware 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kabachello/codiware 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 131
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 38
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-01