PHP code example of igeek / rector-html-output

1. Go to this page and download the library: Download igeek/rector-html-output library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

igeek / rector-html-output example snippets




use Rector\Config\RectorConfig;
use function Igeek\RectorHtmlOutput\withHtmlOutput;

return function (RectorConfig $rectorConfig): void {
    // Standard Rector configuration
    $rectorConfig->paths([__DIR__ . '/app']);

    // Register HTML output formatter
    withHtmlOutput($rectorConfig, __DIR__ . '/rector-reports');
};



use Rector\Config\RectorConfig;
use function Igeek\RectorHtmlOutput\withHtmlOutput;

return function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([__DIR__ . '/app']);

    withHtmlOutput(
        rectorConfig: $rectorConfig,
        outputDirectory: __DIR__ . '/reports',    // Auto-created if missing
        filename: 'my-custom-report',              // Without .html extension
        autoIncrement: true,                       // Auto-increment if file exists
        skipEmpty: true,                           // Skip report if no changes
    );
};



use Rector\Config\RectorConfig;
use Igeek\RectorHtmlOutput\HtmlOutputFormatter;
use Igeek\RectorHtmlOutput\Config\HtmlOutputConfig;
use Igeek\RectorHtmlOutput\Template\TemplateRenderer;
use Igeek\RectorHtmlOutput\Template\PlaceholderReplacer;
use Rector\ChangesReporting\Contract\Output\OutputFormatterInterface;

return function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([__DIR__ . '/app']);

    $rectorConfig->singleton(HtmlOutputConfig::class, fn() => new HtmlOutputConfig(
        outputDirectory: __DIR__ . '/rector-reports',
        filename: 'my-report',
    ));
    $rectorConfig->singleton(PlaceholderReplacer::class);
    $rectorConfig->singleton(TemplateRenderer::class, fn($c) => new TemplateRenderer(
        $c->get(HtmlOutputConfig::class)->getTemplatePath(),
        $c->get(PlaceholderReplacer::class)
    ));
    $rectorConfig->singleton(HtmlOutputFormatter::class);
    $rectorConfig->tag(HtmlOutputFormatter::class, OutputFormatterInterface::class);
};