Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2025-07-15 (14 days ago)  | | Not yet rated by the users | | Total: Not yet counted | | Not yet ranked |
Version | | License | | PHP version | | Categories |
php-box-designer 1.0 | | Custom (specified... | | 8 | | Graphics, Console, PHP 8 |
|
Description | | Author |
This package can draw text boxes to display in a terminal console.
It provides a box class that can create boxes that can have specific width and height in terms of the number of characters that the boxes will occupy in a terminal console where the boxes are displayed.
The box class can output ASCII or UTF8 characters to display the boxes.
It can display a given text inside a box and the style of the border can be changed to use different box decoration styles. | |
 |
|
Innovation award
 Nominee: 2x |
|
Instructions
Example
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use BoxDesigner\CustomBorder;
use BoxDesigner\PreBuilt\DarkerBorder;
use BoxDesigner\PreBuilt\DoubleLineBorder;
use BoxDesigner\Box;
use BoxDesigner\SideLessThanOneException;
$doubleBorder = new DoubleLineBorder();
$darkerBorder = new DarkerBorder();
$output_filtered = fn(string $input): string => htmlspecialchars($input, ENT_QUOTES, 'UTF-8') . PHP_EOL;
try {
$box = new Box(1, 1);
echo $output_filtered($box->draw());
$box = new Box(1, 1);
$single = $box->draw();
$box = new Box(3, 3);
$box->setContentInsideBox($single);
$double = $box->draw($doubleBorder);
$box = new Box(5, 5);
$box->setContentInsideBox($double);
echo $output_filtered($box->draw($darkerBorder));
$customBorder = new CustomBorder('*', '*', '*', '*', '-', '|');
$box = new Box(8, 3);
echo $output_filtered($box->draw($customBorder));
$box = new Box(10, 1);
echo $output_filtered($box->draw());
$box = new Box(8, 3);
$box->setContentInsideBox('John Doe Lorem Ipsum Dolor Sit Amet');
echo $output_filtered($box->draw());
$box = new Box(16, 2);
$box->setContentInsideBox("by terremoth\nand friends");
echo $output_filtered($box->draw());
$box = new Box(2, 2);
$draw = $output_filtered($box->draw());
$box = new Box(4, 4);
$box->setContentInsideBox($draw);
$output_filtered($box->draw($doubleBorder));
echo $output_filtered($box->draw($doubleBorder));
} catch (SideLessThanOneException $e) {
echo $output_filtered($e->getMessage());
}//end try
|
Details
PHP Box Designer
Boxes. There are Boxes. Everywhere.
Simple app that draws boxes using chars with or without text content inside.
This repo main idea is to demonstrate the highest state of the art a PHP repo can be.

See demos/drawing.php for examples.
Installation
composer require terremoth/php-box-designer
What it looks like?

|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.