candycore/candy-mold
最新稳定版本:v0.2.0
Composer 安装命令:
composer create-project candycore/candy-mold
包简介
Skeleton repo for bootstrapping a SugarCraft TUI app — `composer create-project sugarcraft/candy-mold my-app`. Ships a runnable counter Model wired through Program, plus a docs-as-code walkthrough that maps every file to the concept it demonstrates.
README 文档
README
CandyMold
Skeleton repo for bootstrapping a SugarCraft TUI app. Pour your model into the mold and you've got a working app.
composer create-project sugarcraft/candy-mold my-app
cd my-app
./bin/start
and you'll see a working counter. Replace src/Counter.php with your own Model, keep editing.
What you get
my-app/
├── composer.json # requires candy-core + candy-sprinkles
├── phpunit.xml
├── bin/start # entry point — runs Program(new Counter())
├── src/
│ └── Counter.php # demo Model with up/down/quit, styled border
└── tests/
└── CounterTest.php
bin/start is just three meaningful lines: load the autoloader, instantiate your Model, hand it to Program::run(). The Program harness owns the event loop, render tick, signal handling, raw-mode setup, and alt-screen lifecycle — you only write Models.
Anatomy of a SugarCraft Model
A Model is three pure methods:
public function init(): ?\Closure; // optional startup Cmd (timers, fetch...) public function update(Msg $msg): array; // [nextModel, ?Cmd] public function view(): string; // current frame
The shape is borrowed verbatim from Bubble Tea / The Elm Architecture. State lives on the value object, transitions are pure functions, side effects (timers, HTTP, file I/O) get scheduled as Cmds rather than executed inline.
update() always returns a new Model rather than mutating $this. That's why the demo declares public readonly int $n — the only way to "change" the count is to construct a fresh Counter with the new value.
Common next steps
| Want to… | Reach for… |
|---|---|
| Add a text input | sugarcraft/sugar-bits — TextInput |
| Show a spinner while loading | sugarcraft/sugar-bits — Spinner |
| Render Markdown help text | sugarcraft/candy-shine — Renderer |
| Tail a log into a scrollable pane | sugarcraft/sugar-bits — Viewport |
| Build a multi-page wizard | sugarcraft/sugar-prompt — Group |
| Plot a sparkline | sugarcraft/sugar-charts — Sparkline |
Make it ssh-accessible |
sugarcraft/candy-wish |
Add the dep, import its classes, return them from view(). They're all pure renderers on the same Style-based vocabulary.
Testing
composer install vendor/bin/phpunit
The included tests/CounterTest.php shows how to test update() deterministically by constructing Msg objects directly. No event loop, no terminal, no mocking — just call methods and assert the returned tuple.
License
MIT.
candycore/candy-mold 适用场景与选型建议
candycore/candy-mold 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 05 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bootstrap」 「template」 「Skeleton」 「starter」 「create-project」 「tui」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 candycore/candy-mold 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 candycore/candy-mold 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 candycore/candy-mold 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
Simple ASCII output of array data
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
E2E Studios PHP Framework adaptation of leafsphp/blade package
Selectize Theme for Bootstrap 4
Slim starter / Slim skeleton package to boost your development with Slim framework
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 47
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-07
