Installation:
composer require hiqdev/hidev-readme
Ensure you're using HiDev (the parent tool) as a dependency in your project.
Configuration:
Add to your hidev-config.php (or equivalent HiDev config file):
return [
'plugins' => [
'hiqdev/hidev-readme' => [
'enabled' => true,
'template' => '@root/templates/README.md.twig', // Path to your Twig template
],
],
];
First Use Case:
Generate a basic README.md by running:
hidev readme:generate
This will render your template with default sections (e.g., badges, project info).
Template-Based Generation:
@root/templates/README.md.twig) to define structure.# {{ project.name }}
[ }})]({{ project.travisUrl }})
## Installation
```bash
composer require {{ project.name }}
Dynamic Sections:
project object (e.g., {{ project.description }}, {{ project.authors }}).'sections' => [
'usage' => '@root/templates/sections/usage.md.twig',
'contributing' => '@root/templates/sections/contributing.md.twig',
],
Badge Integration:
markdownBadges (e.g., {{ badge('github-actions') }}) for dynamic badges.hidev-config.php:
'badges' => [
'github-actions' => 'https://github.com/{vendor}/{name}/workflows/{workflow}/badge.svg',
],
CLI Integration:
hidev readme:generate to regenerate README.md after changes.hidev readme:watch (if supported) for live updates during development.Laravel-Specific:
project object to Laravel’s composer.json metadata:
'project' => [
'name' => 'vendor/package',
'description' => json_decode(file_get_contents('composer.json'))->description,
],
$this->app->singleton('hidev.config', function () {
return require __DIR__.'/../../hidev-config.php';
});
Custom Templates:
resources/views/hidev/ (Laravel convention).README.md.twig) in your project.CI/CD:
.github/workflows/:
- name: Generate README
run: vendor/bin/hidev readme:generate
Deprecated Dependencies:
Twig_Loader_String (deprecated in Twig 2.x). Update to Twig_Loader_Array if needed:
'template' => ['README.md' => '{{ include("README.md.twig") }}'],
Config Overrides:
hiqdev/hidev-readme to a stable release (e.g., 0.6.2).Badge URL Generation:
badgeUrl('travis')) may break if services rename endpoints. Override in config:
'badges' => [
'travis' => 'https://api.travis-ci.com/{vendor}/{name}.svg?branch=master',
],
Template Caching:
hidev cache:clear
Dry Runs:
Use hidev readme:generate --dry-run to preview output without writing files.
Template Errors: Check Twig syntax with:
vendor/bin/twig README.md.twig
HiDev Debug Mode: Enable verbose output:
HIDEV_DEBUG=1 hidev readme:generate
Custom Badges:
Extend markdownBadges in config to support new services (e.g., GitLab, Codecov).
Section Hooks: Add pre/post-generation hooks via HiDev’s event system:
'events' => [
'readme.beforeGenerate' => function () {
// Modify project data dynamically
},
],
Multi-Format Support:
Generate README.txt alongside README.md by adding:
'formats' => ['md', 'txt'],
Laravel Mix Integration:
Process README.md through Laravel Mix for syntax highlighting:
mix.postCss('resources/css/README.css', 'public/css', [
require('prismjs'),
]);
How can I help you explore Laravel packages today?