Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mkgor/highlighter

Library, which allows you to highlight your PHP code in console (terminal)
https://github.com/mkgor/highlighter

ascii code composer-package highlight php syntax syntax-highlighting terminal

Last synced: about 2 months ago
JSON representation

Library, which allows you to highlight your PHP code in console (terminal)

Awesome Lists containing this project

README

        

# Highlighter
Library, which allows you to highlight your PHP code in terminal

## Installation
Installation via composer:

````
composer require mkgor/highlighter
````

## Printing whole file
````php
getWholeFile(__FILE__);
````

#### Result
![Result](https://i.imgur.com/TC1mP2u.png)

## Printing code snippet (and highlighting specified line)
````php
getSnippet(__FILE__, 3);
````

#### Result

![Result](https://i.imgur.com/iqEfh0d.png)

## Printing code snippet with specified lines
````php
getSpecifiedSnippet(__FILE__, 3, 5);
````

#### Result

![Result](https://i.imgur.com/uuajqgQ.png)

## Printing single line
````php
getLine(__FILE__, 3);
````
#### Result

![Result](https://i.imgur.com/qfJWGrP.png)

##
You can use same functions with suffix `WithoutNumbers` to highlight code without line numbers:

```php
getWholeFileWithoutNumbers(__FILE__);
```

#### Result

![Result](https://i.imgur.com/F7Mo4Rq.png)

## Themes

This highlighter supports custom themes. It has built-in themes, but you can create your own by implementing ```Highlighter\Theme\ThemeInterface```

So, to set theme, just call ```setTheme``` method of Highlighter

```php
setTheme(new Highlighter\Theme\DefaultThemes\Minimalistic());

echo $highlighter->getWholeFile(__FILE__);
```

#### Built-in themes:

##### Minimalistic

![Theme](https://i.imgur.com/0qGTZ1G.png)

##### Light

![Theme](https://i.imgur.com/zp4i1Di.png)

##### Material

![Theme](https://i.imgur.com/vENEwe1.png)