PHPackages                             area17/phptorch - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. area17/phptorch

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

area17/phptorch
===============

Torchlight helpers for php files

216.5k↓18.2%12PHPCI passing

Since Apr 29Pushed 1y ago3 watchersCompare

[ Source](https://github.com/area17/phptorch)[ Packagist](https://packagist.org/packages/area17/phptorch)[ RSS](/packages/area17-phptorch/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (2)

PhpTorch 🔦
==========

[](#phptorch-)

PhpTorch is a package for documentation purposes. It uses [nikic/php-parser](https://github.com/nikic/PHP-Parser)to parse a php class, which can then be modified using highlighting actions.

The end result will be printed as code with [torchlight](https://torchlight.dev) annotations.

Example:

```
$highlighter = \A17\PhpTorch\Highlight::new('PageController.php')
  ->focusMethods('getForm')
  ->diffImports(\A17\Twill\Services\Forms\Fields\Medias::class)
  ->focusImports(\A17\Twill\Services\Forms\Fields\Medias::class)
  ->diffInMethod('getForm', 7, 9);
```

Then you can provide the output to torchlight which will result in:

[![screenshot](screenshot.png)](screenshot.png)

Available methods
-----------------

[](#available-methods)

For now check [the highlighter class public methods](./src/Highlight.php) or consult the tests.

Todo
----

[](#todo)

- Add support for non class files.

Examples
--------

[](#examples)

### Direct usage

[](#direct-usage)

```
$highlighter = \A17\PhpTorch\Highlight::new('PageController.php')
  ->focusMethods('getForm')
  ->diffImports(\A17\Twill\Services\Forms\Fields\Medias::class)
  ->focusImports(\A17\Twill\Services\Forms\Fields\Medias::class)
  ->diffInMethod('getForm', 7, 9);
```

### Jigsaw / markdown

[](#jigsaw--markdown)

If you want to use this in Jigsaw, you should require `"torchlight/torchlight-jigsaw": "^0.3.4",` in addition to this package.

Then you can start a code snippet with 3 backticks followed by phptorch like this:

```
\```phptorch
{ JSON }
##CODE##
