PHPackages                             batyo/php-cli-display-library - 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. batyo/php-cli-display-library

ActiveLibrary

batyo/php-cli-display-library
=============================

PHP CLI表示ライブラリ（ANSIカラー、フォント、文字幅対応）

v1.0.1(1mo ago)02↑2900%MITPHPPHP &gt;=7.4

Since Mar 23Pushed 1mo agoCompare

[ Source](https://github.com/batyo/php-cli-display-library)[ Packagist](https://packagist.org/packages/batyo/php-cli-display-library)[ RSS](/packages/batyo-php-cli-display-library/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

PHP CLI Display Library
=======================

[](#php-cli-display-library)

マルチバイト文字に対応したPHP用CLI表示ライブラリです。
ANSIカラー、文字装飾、フォント切り替え、エンコード自動判別とUTF-8統一対応を備えています。

---

特徴
--

[](#特徴)

- **日本語対応**：`mb_strwidth`による全角・半角文字幅計算
- **エンコード自動判別＆UTF-8統一**：`EncodingHelper`で自動変換
- **ANSIカラー・装飾**：前景色・背景色・太字・下線に対応
- **フォント切り替え**：`FontDriverInterface`で拡張可能（FIGlet等）
- **シンプルな単一ファイル構成**：Composerオートロードもサポート

---

使い方
---

[](#使い方)

### 基本例

[](#基本例)

```
use CLI\Display\AnsiRenderer;
use CLI\Display\Style;

$renderer = new AnsiRenderer();
$style = new Style('bright_green', null, true);
echo $renderer->render('こんにちは、世界！', $style) . "\n";
```

### Displayクラスによる高機能表示

[](#displayクラスによる高機能表示)

```
use CLI\Display\Display;
use CLI\Display\AnsiRenderer;
use CLI\Display\ExternalFigletFontDriver;
use CLI\Display\Style;

$d = new Display(new AnsiRenderer(), new ExternalFigletFontDriver());
$d->header('サンプル', 'standard', new Style('cyan', null, true));
$d->box("日本語のボックス表示をテストします。全角幅にも対応しています。", 40, new Style('green'));
$d->text($d->colorText('赤文字の例', 'red'));
```

---

エンコード自動判別・文字幅取得
---------------

[](#エンコード自動判別文字幅取得)

```
use CLI\Display\EncodingHelper;

$text = "テスト"; // Shift_JISでもOK
$utf8 = EncodingHelper::normalizeEncoding($text);
$width = EncodingHelper::getDisplayWidth($utf8);
```

---

利用できる色名
-------

[](#利用できる色名)

- `black, red, green, yellow, blue, magenta, cyan, white`
- `bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white`

---

フォント拡張
------

[](#フォント拡張)

`FontDriverInterface`を実装することで独自フォント描画機能を追加できます。

```
class MyFontDriver implements CLI\Display\FontDriverInterface {

## インストール

Composer での簡単なインストール例:

```bash
composer require batyo/php-cli-display-library
```

---

注意事項
----

[](#注意事項)

- `ExternalFigletFontDriver` を利用してヘッダを FIGlet フォントで表示するには、システムに `figlet` コマンドがインストールされている必要があります。利用できない場合は自動でフォールバック表示になります。
- Windows の一部の端末では ANSI エスケープシーケンスが有効になっていないため色や装飾が表示されないことがあります。Windows Terminal や最新の PowerShell を使用するか、端末で ANSI を有効化してください。

---

ライセンス
-----

[](#ライセンス)

MIT License

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance97

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7532877b1c6647d2eda9053f0b8dde8f32464536262fbc2e3657f6b9e1b5b3f9?d=identicon)[batyo](/maintainers/batyo)

---

Top Contributors

[![batyo](https://avatars.githubusercontent.com/u/145861929?v=4)](https://github.com/batyo "batyo (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/batyo-php-cli-display-library/health.svg)

```
[![Health](https://phpackages.com/badges/batyo-php-cli-display-library/health.svg)](https://phpackages.com/packages/batyo-php-cli-display-library)
```

PHPackages © 2026

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