stoffel/console-sourcecode

使用Symfony Console Component渲染源代码的辅助工具

0.1 2020-11-30 18:10 UTC

This package is auto-updated.

Last update: 2024-08-29 05:18:23 UTC


README

使用Symfony Console Component渲染源代码的辅助工具。

示例

$ git clone git@github.com:chr-hertel/console-sourcecode.git
$ cd console-image
$ composer install
$ example/php-code
$ example/php-file

安装

$ composer require stoffel/console-sourcecode

在PHP中的使用

use Stoffel\Console\SourceCode\SourceCodeHelper;

// print code from variable
SourceCodeHelper::create($output)
    ->write($code);

// print code from file
SourceCodeHelper::create($output)
    ->writeFile('/path/to/source-file.php');

// print only an excerpt
SourceCodeHelper::create($output)
    ->writeFile('/path/to/source-file.php', 59, 17);

// chose one of the predefined themes
SourceCodeHelper::create($output)
    ->useTheme('seti')
    ->writeFile('/path/to/source-file.php');

// disable line numbers
SourceCodeHelper::create($output)
    ->disableLineNumbers()
    ->writeFile('/path/to/source-file.php');