<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jeffersongoncalves / laravel-github-readme example snippets
use JeffersonGoncalves\GitHubReadme\GitHubReadme;
use JeffersonGoncalves\HtmlSanitizer\Facades\HtmlSanitizer; // example sanitizer
// Fetch the default-branch README, rendered to HTML and cached on disk.
$html = GitHubReadme::fetchHtml('https://github.com/owner/repo');
// Fetch a specific branch/tag/ref.
$html = GitHubReadme::fetchHtml('https://github.com/owner/repo', '2.x');
// ALWAYS sanitize before display — the HTML is untrusted.
echo HtmlSanitizer::clean($html);
// Open off-site links in a new tab with rel="nofollow noopener".
$html = GitHubReadme::markExternalLinks($html, 'mysite.test');
// Lazy-load every image except the first (kept eager as the LCP candidate).
$html = GitHubReadme::lazyloadImages($html);
// Wrap wide tables in a horizontally-scrollable container.
$html = GitHubReadme::wrapTables($html);
return [
// The filesystem disk used to store rendered README HTML files.
'disk' => env('GITHUB_README_DISK', 'local'),
// Minutes a freshly verified README is served without contacting GitHub.
'check_interval_minutes' => (int) env('GITHUB_README_CHECK_INTERVAL', 10),
// Optional GitHub token (falls back to config('services.github.token')).
'token' => env('GITHUB_TOKEN', env('GITHUB_README_TOKEN')),
// User-Agent header sent on every GitHub API request.
'user_agent' => env('GITHUB_README_USER_AGENT', 'laravel-github-readme'),
// Request timeout in seconds.
'timeout' => (int) env('GITHUB_README_TIMEOUT', 8),
// Optional renderer callable: fn (string $markdown): string.
// Null uses the internal League\CommonMark renderer (GFM + heading permalinks).
'renderer' => null,
];