{"id":15355067,"url":"https://github.com/adhocore/php-cli-syntax","last_synced_at":"2025-07-20T11:34:08.790Z","repository":{"id":56940838,"uuid":"229348504","full_name":"adhocore/php-cli-syntax","owner":"adhocore","description":"PHP Code Syntax Highlighter and/or exporter for CLI. Zero Dependency.","archived":false,"fork":false,"pushed_at":"2023-05-21T14:29:41.000Z","size":517,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-23T01:28:32.237Z","etag":null,"topics":["adhocore","cli-syntax","cli-syntax-highlight","code-screenshot","code-to-image","export-php-code","php","php-code-highlight","php7","syntax-highlighting"],"latest_commit_sha":null,"homepage":"https://github.com/adhocore/php-cli-syntax","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/adhocore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"adhocore","custom":["https://paypal.me/ji10"]}},"created_at":"2019-12-20T23:02:47.000Z","updated_at":"2023-06-19T06:09:40.000Z","dependencies_parsed_at":"2025-04-15T06:17:39.332Z","dependency_job_id":"ec2c8da5-ee28-495f-a0db-a5e138219571","html_url":"https://github.com/adhocore/php-cli-syntax","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/adhocore/php-cli-syntax","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cli-syntax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cli-syntax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cli-syntax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cli-syntax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adhocore","download_url":"https://codeload.github.com/adhocore/php-cli-syntax/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-cli-syntax/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266117909,"owners_count":23879145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["adhocore","cli-syntax","cli-syntax-highlight","code-screenshot","code-to-image","export-php-code","php","php-code-highlight","php7","syntax-highlighting"],"created_at":"2024-10-01T12:22:22.860Z","updated_at":"2025-07-20T11:34:08.768Z","avatar_url":"https://github.com/adhocore.png","language":"PHP","readme":"## adhocore/cli-syntax\n\n[![Latest Version](https://img.shields.io/github/release/adhocore/php-cli-syntax.svg?style=flat-square)](https://github.com/adhocore/php-cli-syntax/releases)\n[![Travis Build](https://img.shields.io/travis/com/adhocore/php-cli-syntax.svg?branch=master\u0026style=flat-square)](https://travis-ci.com/adhocore/php-cli-syntax?branch=master)\n[![Scrutinizer CI](https://img.shields.io/scrutinizer/g/adhocore/php-cli-syntax.svg?style=flat-square)](https://scrutinizer-ci.com/g/adhocore/php-cli-syntax/?branch=master)\n[![Codecov branch](https://img.shields.io/codecov/c/github/adhocore/php-cli-syntax/master.svg?style=flat-square)](https://codecov.io/gh/adhocore/php-cli-syntax)\n[![StyleCI](https://styleci.io/repos/229348504/shield)](https://styleci.io/repos/229348504)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](./LICENSE)\n\n\n```\n        _   _          _\n  ___  | | (_)  ___   | |__\n / __| | | | | / __|  '  _  \\\n| (__  | | | | \\___ \\ | | | |\n \\___| |_| |_| |____/ |_| |_|\n\nPHP CLI Syntax Highlight Tool\n=============================\n```\n\n## Installation\n\n### As phar binary\n\n```sh\ncurl -SsLo ~/clish.phar https://github.com/adhocore/php-cli-syntax/releases/latest/download/clish.phar\n\nchmod +x ~/clish.phar \u0026\u0026 sudo ln -s ~/clish.phar /usr/local/bin/clish\n```\n\u003e Follow same steps to upgrade.\n\n### As standalone binary\n\n```sh\ncomposer global require adhocore/cli-syntax\n```\n\u003e Follow same steps to upgrade.\n\n### As project dependency\n```bash\ncomposer require adhocore/cli-syntax\n```\n\n## Usage\n\n### Shell command\n\nIf you installed as binary following any of the above methods, then:\n\n```sh\n# you will be able to run it as\nclish -h\nclish -f file.php\necho '\u003c?php date(\"Ymd\");' | clish\ncat file.php | clish\n\n# export png\nclish -f file.php -o file.png\n```\n\n\u003e `clish` stands for CLI syntax highlight.\n\n#### Options\n\nParameter options:\n\n```\n  [-e|--echo]            Forces echo to STDOUT when --output is passed\n  [-f|--file]            Input PHP file to highlight and/or export\n                         (will read from piped input if file not given)\n  [-F|--font]            Font to use for export to png\n  [-l|--with-line-no]    Highlight with line number\n  [-o|--output]          Output filepath where PNG image is exported\n```\n\n\u003e Run `clish -h` to show help.\n\n##### Examples\n\n```sh\n  bin/clish --file file.php                           # print\n  cat file.php | bin/clish                            # from piped stream\n  bin/clish \u003c file.php                                # from redirected stdin\n  bin/clish --file file.php --output file.png         # export\n  bin/clish --file file.php --output file.png --echo  # print + export\n  bin/clish --file file.php --with-line-no            # print with lineno\n  bin/clish -f file.php -o file.png -F dejavu         # export in dejavu font\n```\n\n### Programatically\n\nYou can either highlight PHP code in terminal output or export to png image.\n\n#### Highlight\n\n```php\nuse Ahc\\CliSyntax\\Highlighter;\n\n// PHP code\necho new Highlighter('\u003c?php echo \"Hello world!\";');\n// OR\necho (new Highlighter)-\u003ehighlight('\u003c?php echo \"Hello world!\";', $options);\n\n// PHP file\necho Highlighter::for('/path/to/file.php', $options);\n\n// $options array is optional and can contain:\n[\n    'lineNo' =\u003e true, // bool\n];\n```\n\n#### Export\n\n```php\nuse Ahc\\CliSyntax\\Exporter;\n\n// PHP file\nExporter::for('/path/to/file.php')-\u003eexport('file.png', $options);\n\n// $options array is optional and can contain:\n[\n    'lineNo' =\u003e true, // bool\n    'font'   =\u003e 'full/path/of/font.ttf', // str\n    'size'   =\u003e 'font size', // int\n];\n```\n\nSee [example usage](./example.php). Here's how the export looks like:\n\n![adhocore/cli-syntax](./example.png)\n\n---\nAnd with line numbers:\n\n![Example with line numbers](https://imgur.com/Jqiydf8.png)\n\n## Customisation\n\nIf you would like to change color etc, extend the classes\n[`Highlighter`](./src/Highlighter.php) and [`Exporter`](./src/Exporter.php),\nthen override `visit()` method which recieves [`DOMNode`](https://php.net/DOMNode).\n\n## Contributing\n\nPlease check [the guide](./CONTRIBUTING.md).\n\n## LICENSE\n\n\u003e \u0026copy; [MIT](./LICENSE) | 2019, Jitendra Adhikari\n\n## Credits\n\nThis project is bootstrapped by [phint](https://github.com/adhocore/phint)\nand releases managed by [please](https://github.com/adhocore/please).\n","funding_links":["https://github.com/sponsors/adhocore","https://paypal.me/ji10"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhocore%2Fphp-cli-syntax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadhocore%2Fphp-cli-syntax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhocore%2Fphp-cli-syntax/lists"}