{"id":15805282,"url":"https://github.com/sevenecks/ansi","last_synced_at":"2026-04-27T22:32:50.380Z","repository":{"id":62542815,"uuid":"113604609","full_name":"sevenecks/ansi","owner":"sevenecks","description":"Colorize text for terminal output in PHP","archived":false,"fork":false,"pushed_at":"2018-09-11T19:29:40.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-30T21:49:12.505Z","etag":null,"topics":["ansi","bash","colors","php","static"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sevenecks.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-08T18:22:50.000Z","updated_at":"2023-08-26T05:01:00.000Z","dependencies_parsed_at":"2022-11-02T16:00:45.372Z","dependency_job_id":null,"html_url":"https://github.com/sevenecks/ansi","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/sevenecks/ansi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevenecks%2Fansi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevenecks%2Fansi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevenecks%2Fansi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevenecks%2Fansi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sevenecks","download_url":"https://codeload.github.com/sevenecks/ansi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevenecks%2Fansi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32358509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi","bash","colors","php","static"],"created_at":"2024-10-05T02:07:12.436Z","updated_at":"2026-04-27T22:32:50.364Z","avatar_url":"https://github.com/sevenecks.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Installation\n```bash\ncomposer require sevenecks/ansi\n```\n\n## Colorize\n\n### Usage\n\n#### Static Usage\nThe methods on Colorize can be called statically and the full API is listed later. \n\n```php\nrequire_once __DIR__ . '/vendor/autoload.php';\nuse SevenEcks\\Ansi\\Colorize;\n\n$test_string = 'This is a test';\n\necho Colorize::italic($test_string) . \"\\n\";\necho Colorize::cyan($test_string) . \"\\n\";\necho Colorize::bgRed($test_string) . \"\\n\";\n// background color first\necho Colorize::cyan(Colorize::bgRed($test_string)) . \"\\n\";\n// manually call the colorize string function\necho Colorize::colorizeString(\"TEST STRING\", Colorize::$FOREGROUND_BLUE);\n```\n\n#### Instantiated Usage\nColorize also supports a magic method that will allow you to call the static methods dynamically, if you want to instantiate the Colorize class. This can be useful for dependency injection.\n\n```php\nrequire_once __DIR__ . '/vendor/autoload.php';\nuse SevenEcks\\Ansi\\Colorize;\n\n$test_string = 'This is a test';\n\n$colorize = new Colorize;\n\necho $color-\u003ered('tester');\necho $color-\u003edarkGray('testy mctesterson');\n```\n\n### Colors\n\nThere are several colors available for foreground and background.\n\n#### Foreground\n\nColorize::italic\nColorize::bold\nColorize::underline\nColorize::invert\nColorize::darkGray\nColorize::blue\nColorize::lightBlue\nColorize::green\nColorize::lightGreen\nColorize::cyan\nColorize::lightCyan\nColorize::red\nColorize::lightRed\nColorize::purple\nColorize::lightPurple\nColorize::brown\nColorize::yellow\nColorize::lightGray\nColorize::white\n\n#### Background\n\nColorize::bgBlack\nColorize::bgRed\nColorize::bgGreen\nColorize::bgYellow\nColorize::bgBlue\nColorize::bgMagenta\nColorize::bgCyan\nColorize::bgLightGray\n\n## API\n```php\n//foreground colors\npublic static $FOREGROUND_BLACK = '0;30';\npublic static $FOREGROUND_DARK_GRAY = '1;30';\npublic static $FOREGROUND_BLUE = '0;34';\npublic static $FOREGROUND_LIGHT_BLUE = '1;34';\npublic static $FOREGROUND_GREEN = '0;32';\npublic static $FOREGROUND_LIGHT_GREEN = '1;32';\npublic static $FOREGROUND_CYAN = '0;36';\npublic static $FOREGROUND_LIGHT_CYAN = '1;36';\npublic static $FOREGROUND_RED = '0;31';\npublic static $FOREGROUND_LIGHT_RED = '1;31';\npublic static $FOREGROUND_PURPLE = '0;35';\npublic static $FOREGROUND_LIGHT_PURPLE = '1;35';\npublic static $FOREGROUND_BROWN = '0;33';\npublic static $FOREGROUND_YELLOW = '1;33';\npublic static $FOREGROUND_LIGHT_GRAY = '0;37';\npublic static $FOREGROUND_WHITE = '1;37';\npublic static $FOREGROUND_BOLD = '1';\npublic static $FOREGROUND_UNDERLINE = '4';\npublic static $FOREGROUND_ITALIC = '3'; \npublic static $FOREGROUND_INVERT = '7';\npublic static $FOREGROUND_STRIKEOUT = '9';\n\n// background colors \npublic static $BACKGROUND_BLACK = '40';\npublic static $BACKGROUND_RED = '41';\npublic static $BACKGROUND_GREEN = '42';\npublic static $BACKGROUND_YELLOW = '43';\npublic static $BACKGROUND_BLUE = '44';\npublic static $BACKGROUND_MAGENTA = '45';\npublic static $BACKGROUND_CYAN = '46';\npublic static $BACKGROUND_LIGHT_GRAY = '47'; \n\n/**\n * Dynamically call the static methods from instance variables\n * and provide the correct arguments as needed\n *\n * @param string $name\n * @param array $arguments\n * @return string\n */\npublic function __call($name, $arguments)\n\n/**\n* Colorize a string of text and return it\n*\n* @param string $text\n* @param string $color\n*\n* @return string\n*/\npublic static function colorizeString($text, $color) \n\n/**\n * strikethrough some text \n *\n * @param string $text\n * @return string\n */\npublic static function strikeout($text)\n\n/**\n * invert the foreground of a string\n *\n * @param string $text\n * @return string\n */\npublic static function invert($text)\n\n/**\n * bold the foreground of a string\n *\n * @param string $text\n * @return string\n */\npublic static function bold($text)\n\n/**\n * Italic the foreground of a string\n *\n * @param string $text\n * @return string\n */\npublic static function italic($text)\n\n/**\n * Underline the foreground of a string\n *\n * @param string $text\n * @return string\n */\npublic static function underline($text)\n\n/**\n* Colorize the foreground of a string\n*\n* @param string $text\n* @return string\n*/\npublic static function black($text)\npublic static function darkGray($text)\npublic static function blue($text)\npublic static function lightBlue($text)\npublic static function green($text)\npublic static function lightGreen($text)\npublic static function cyan($text)\npublic static function lightCyan($text)\npublic static function red($text)\npublic static function lightRed($text)\npublic static function purple($text)\npublic static function lightPurple($text)\npublic static function brown($text)\npublic static function yellow($text)\npublic static function lightGray($text)\npublic static function white($text)\n\n/**\n * Colorize the background of a string\n *\n * @param string $text\n * @return string\n */\npublic static function bgBlack($text)\npublic static function bgRed($text)\npublic static function bgGreen($text)\npublic static function bgYellow($text)\npublic static function bgBlue($text)\npublic static function bgMagenta($text)\npublic static function bgCyan($text)\npublic static function bgLightGray($text)\n\n## ColorInterface\n\nYou can use the ColorInterface.php file to implement your own ANSI Colorization class. The interface requires all the functions that the Colorize class implements, but does not care about how you define your colors or what is going on below the hood.\n\n```\n## Change Log\nPlease see [Change Log](CHANGELOG.md) for more information.\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevenecks%2Fansi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsevenecks%2Fansi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevenecks%2Fansi/lists"}