Download the PHP package sugarcraft/candy-core without Composer

On this page you can find all versions of the php package sugarcraft/candy-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package candy-core

SugarCraft

CI codecov Packagist Version PHP

PHP port of charmbracelet/bubbletea — the Elm-architecture TUI runtime at the heart of the Charmbracelet stack.

Requirements

Architecture

Subscriptions

Elm-style subscription reconciliation lets a Model declare recurring events (ticks, key events, signals) without managing timers manually. After each update() cycle the runtime diffs the returned Subscriptions set against the active one — new subscriptions start, dropped ones cancel, stable ones keep running.

The SubscriptionCapable trait satisfies Model::subscriptions() with a null default — use it in Models that don't need subscriptions:

Screen / ScreenStack

Modal and sub-screen workflows use an immutable ScreenStack owned by a ScreenStackCapable root model. The Program routes init() / update() / view() to the active screen automatically, while infrastructure messages (ScreenStackPushedMsg / ScreenStackPoppedMsg) stay in the root model.

examples/screen-stack.php is a runnable demo showing 3-deep push / pop.

Demos

Counter Model

Timer

Status

See ../CONVERSION.md for the full roadmap and the v2 parity sweep table tracking each Bubble Tea v2 / Lipgloss v2 / Bubbles v2 feature.

Companion libraries

SugarCraft is the foundation — the rest of the SugarCraft stack builds on it. From the same monorepo:

See the matchup table in ../MATCHUPS.md for status, package names, and namespace mappings.

Localization (i18n)

candy-core ships a tiny zero-dep translation registry that the rest of the SugarCraft monorepo plugs into. Every library owns a namespace (core, charts, prompt, …) and a lang/<locale>.php file per locale — call sites look strings up by fully-qualified key.

Each library exposes a thin Lang::t($key, $params) wrapper with its namespace baked in, so call sites stay short:

Adding a new locale

  1. Copy candy-core/lang/en.php to candy-core/lang/<locale>.php (e.g. fr.php).
  2. Translate the values, keeping keys and {placeholders} intact.
  3. Set the locale at app startup with T::setLocale('fr') or T::setLocale(T::detect()).

Lookup chain: exact locale → base language → en → raw key. So a single fr.php automatically serves fr-fr, fr-ca, fr-be, etc. — only add a regional file (e.g. pt-br.php) when the wording genuinely diverges from the base language. A forgotten string is visible, never a fatal error.

See LOCALES.md in the SugarCraft monorepo for the recommended set of codes plus a list of every base language a contributor can target.

Application-level overrides

Apps can ship their own translations of any library's strings without patching upstream:

See the SugarCraft\Core\I18n\T docblock for the full API surface (register, translate, setLocale, locale, detect, overrideNamespace, reset).

Composing Cmds

The runtime ships several Cmd combinators. The cheat-sheet below maps Bubble Tea idioms to the PHP equivalents:

Need Use
Run several Cmds in parallel Cmd::batch(...$cmds)
Run several Cmds one-after-the-other Cmd::sequence(...$cmds)
Schedule a Msg in N seconds Cmd::tick($seconds, fn () => $msg)
Schedule a Msg on every wall-clock multiple of N seconds Cmd::every($seconds, fn () => $msg)
Dispatch a Msg right away Cmd::send($msg)
Quit the program Cmd::quit()
Hard-kill (after quit failed) $program->kill() (from outside the loop)
Print text above the program region Cmd::println($s) / Cmd::printf($fmt, ...)
Drop bytes onto the wire Cmd::raw($bytes)
Suspend on Ctrl+Z, resume on SIGCONT Cmd::suspend() (returns to a ResumeMsg)
Run an external program ($EDITOR) Cmd::exec($cmd, $args, fn ($exit) => $msg)

init() returns a Cmd (or null) to fire once at startup. update() returns [Model, ?Cmd] — the runtime applies the Cmd, dispatches its Msg, and feeds the result back into update().

The examples/ directory has runnable demos for each pattern: timer (tick scheduling), realtime (self-rescheduling tick), sequence (Cmd::sequence), send-msg (custom Msg + Cmd::tick), tabs (state-driven view selection), views (multi-view switcher), splash (animated splash → main view), suspend (Cmd::suspend + ResumeMsg), focus-blur, print-key, set-window-title, and prevent-quit.

Alt-screen vs inline mode

Pass useAltScreen: true (the default) to ProgramOptions and the runtime takes over the alt-screen — the user's previous content is preserved underneath, and Cmd::quit() restores it. Best for fullscreen TUIs.

Pass useAltScreen: false + inlineMode: true for a program that shares scrollback with the surrounding shell. The runtime saves the cursor on first frame and restores it after each repaint, so preceding shell output stays visible. Pair with Cmd::println() to emit lines that scroll above the program region.

A typical CandyShell prompt (gum input-style) uses inline mode; a fullscreen filter (gum filter-style) uses alt-screen.

Tutorial — building a shopping list

Every SugarCraft program is three things: a Model (the state), an update (state transitions), and a view (a string). Here's a shopping list that walks through all three.

Three rules carry through to every program:

  1. Model is immutable. update() returns a new Model, never mutates the receiver. This buys you snapshot debugging, time travel, undo — all for free.
  2. Cmds run async. update() decides what should happen; the runtime applies the resulting Cmd. A Cmd is a closure returning a Msg.
  3. view() is pure. Same Model in → same string out. Side effects (writing to disk, hitting an HTTP endpoint, blinking the cursor) all live in Cmds, never in view().

Once you've internalised the loop, every other SugarCraft feature is just a richer Msg or a more interesting Cmd.

Debugging tips

The renderer owns stdout — printing to it from update() or view() will be overwritten on the next frame. The two ways to surface debug info from inside a running program:

  1. Log to a file. Tail the file from another terminal:

  2. Use Cmd::println(). Lines emitted via Cmd::println() print above the program region (alt-screen and inline mode both honour this) — perfect for "I got here" prints during development.

Other gotchas:

Mouse support — cell-motion vs all-motion

Pass MouseMode::CellMotion (only emit motion events while a button is held) or MouseMode::AllMotion (emit every motion event including bare-cursor moves) to ProgramOptions. Pick:

MouseMsg carries a MouseAction enum (Press / Release / Motion / WheelUp / WheelDown) and 1-based col / row coordinates. The four MouseClickMsg / MouseReleaseMsg / MouseMotionMsg / MouseWheelMsg subclasses let you match by class when that's more convenient.

examples/mouse.php is a runnable demonstrator.

Test


All versions of candy-core with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sugarcraft/candy-core contains the following files

Loading the files please wait ...