PHPackages                             sugarcraft/sugar-glow - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. sugarcraft/sugar-glow

ActiveLibrary[CLI &amp; Console](/categories/cli)

sugarcraft/sugar-glow
=====================

PHP port of charmbracelet/glow — Markdown CLI viewer / pager composing CandyShine + Viewport. 8 stock themes, word-wrap, OSC 8 hyperlinks.

10PHP

Since Jul 1Pushed 1mo agoCompare

[ Source](https://github.com/sugarcraft/sugar-glow)[ Packagist](https://packagist.org/packages/sugarcraft/sugar-glow)[ RSS](/packages/sugarcraft-sugar-glow/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![sugar-glow](.assets/icon.png)](.assets/icon.png)

SugarGlow
=========

[](#sugarglow)

[![CI](https://github.com/detain/sugarcraft/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/detain/sugarcraft/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/1d6023a9dc17750dd8046b79bba51bb268f97d6cb8003eef033a2e3245374377/68747470733a2f2f636f6465636f762e696f2f67682f64657461696e2f737567617263726166742f6272616e63682f6d61737465722f67726170682f62616467652e7376673f666c61673d73756761722d676c6f77)](https://app.codecov.io/gh/detain/sugarcraft?flags%5B0%5D=sugar-glow)[![Packagist Version](https://camo.githubusercontent.com/f1a829cab23422cf08c820faa597753b351b54fb63c47b83227f12601dd838d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737567617263726166742f73756761722d676c6f773f6c6162656c3d7061636b6167697374)](https://packagist.org/packages/sugarcraft/sugar-glow)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/e78ffc83837c0d12647811a7fd1910c3cbeae04988de94bb4fd5b67e0874696a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135382e312d3838393262662e737667)](https://www.php.net/)

[![demo](.vhs/render.gif)](.vhs/render.gif)

PHP port of [charmbracelet/glow](https://github.com/charmbracelet/glow) — a Markdown CLI viewer that composes **CandyShine** (rendering) and **SugarBits Viewport** (scrolling).

```
composer require sugarcraft/sugar-glow
```

CLI
---

[](#cli)

```
sugarglow README.md                            # render to stdout (default)
sugarglow -p README.md                         # open in a fullscreen pager
git log -1 --pretty=%B | sugarglow -p          # pipe stdin
sugarglow --theme dracula README.md
sugarglow --width 80 --no-hyperlinks README.md
sugarglow --theme-config ./my-theme.json README.md
```

Flags:

- `--theme {ansi|plain|dark|light|notty|dracula|tokyo-night|pink|solarized|monokai|github}`— picks a CandyShine preset. `solarized`, `monokai`, and `github` load JSON theme files from `themes/`.
- `--style` / `-s` — alias for `--theme` (glamour-compat).
- `--theme-config ` — load a custom JSON theme via `Theme::fromJson`. Overrides `--theme`.
- `--width` / `-w ` — word-wrap paragraphs / blockquotes / list bodies. 0 = no wrap.
- `--no-hyperlinks` — disable OSC 8 link envelopes; render links as `text (url)` instead.
- `--pager` / `-p` — open in a fullscreen pager.

Pager keys
----------

[](#pager-keys)

Standard reader keys come from `Viewport`:

KeyAction`↑` / `k`line up`↓` / `j`line down`PgUp` / `b`page up`PgDn` / `space` / `f`page down`Ctrl+U` / `Ctrl+D`half page`Home` / `g`top`End` / `G`bottom`q` / `Esc` / `Ctrl+C`exitDemos
-----

[](#demos)

### Render to stdout

[](#render-to-stdout)

[![render](.vhs/render.gif)](.vhs/render.gif)

### Fullscreen pager

[](#fullscreen-pager)

[![pager](.vhs/pager.gif)](.vhs/pager.gif)

Library API
-----------

[](#library-api)

Beyond the CLI, sugar-glow exposes three utility classes for integrating its behaviour into other PHP projects.

### GlamourTheme

[](#glamourtheme)

Loads and parses Glamour-style theme JSON files (block\_prefix/suffix, indent\_token, margin, chroma token mapping).

```
use SugarCraft\Glow\GlamourTheme;

// From a JSON string
$theme = GlamourTheme::fromJson(file_get_contents('./my-theme.json'));

// From a file path
$theme = GlamourTheme::fromFile('./my-theme.json');

// Resolve a chroma token to an SGR color code (e.g., "31" for red)
$sgr = $theme->resolve('emphasis'); // => "31" or null
```

### FileWatcher

[](#filewatcher)

File watching via mtime polling — works cross-platform with no extensions.

```
use SugarCraft\Glow\FileWatcher;

$watcher = new FileWatcher('/path/to/file.md');

// Check if modified since a given mtime
if ($watcher->hasChangedSince($lastMtime)) {
    // re-render
}

// Generator-based watch loop (e.g., in a ReactPHP stream)
foreach (FileWatcher::watch('/path/to/file.md', 500) as $changed) {
    // $changed === true each time the file is modified
}
```

### Width helpers

[](#width-helpers)

CJK and emoji width handling lives in `SugarCraft\Core\Util\Width`. Use it directly for visual truncation, padding, and ANSI-aware measurement:

```
use SugarCraft\Core\Util\Width;

Width::string('hello');           // 5
Width::string('你好');            // 4 (full-width)
Width::string('📦');              // 2 (emoji)

Width::padRight('hi', 8);         // "hi      "
Width::truncate('hello world', 8); // "hello wo"
```

Shared foundations
------------------

[](#shared-foundations)

sugar-glow uses **candy-palette** for terminal capability probing. The `RenderCommand::terminalSupportsColor()` wrapper calls `\SugarCraft\Palette\Probe\TerminalProbe::run()` and falls back to `true` (assume color) if the probe throws — ensuring graceful degradation on Windows, over SSH, and in old terminals.

Snapshot tests
--------------

[](#snapshot-tests)

Render output is covered by golden-file snapshot tests. Fixture files live in `tests/fixtures/` with a `.golden` extension and are compared against actual ANSI byte output via `SugarCraft\Testing\Snapshot\Assertions::assertGoldenAnsi()`. To re-record fixtures after intentional output changes:

```
UPDATE_GOLDENS=1 vendor/bin/phpunit
```

Test
----

[](#test)

```
cd sugar-glow && composer install && vendor/bin/phpunit
```

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance59

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 99% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1036e0717211b8030b83cbe729e8ba6ba442fdbd5285fb97a39d7dcfe339342?d=identicon)[detain](/maintainers/detain)

---

Top Contributors

[![detain](https://avatars.githubusercontent.com/u/1364504?v=4)](https://github.com/detain "detain (103 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

ansicandycorecharmclidraculaglowglow-porthyperlinkmarkdownmarkdown-viewernordpagerpinkreadmescrollbackterminalthemestokyo-nighttuiword-wrap

### Embed Badge

![Health badge](/badges/sugarcraft-sugar-glow/health.svg)

```
[![Health](https://phpackages.com/badges/sugarcraft-sugar-glow/health.svg)](https://phpackages.com/packages/sugarcraft-sugar-glow)
```

###  Alternatives

[illuminate/console

The Illuminate Console package.

13046.0M6.8k](/packages/illuminate-console)[styleci/cli

The CLI tool for StyleCI

71470.5k9](/packages/styleci-cli)[winbox/args

Windows command-line formatter

20720.9k21](/packages/winbox-args)[mallardduck/laravel-traits

A collection of useful Laravel snippets in the form of easy to use traits.

136.2k2](/packages/mallardduck-laravel-traits)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
