A beautiful Laravel package for viewing Markdown documentation with GitHub-style rendering
smmahfujurrahman/docgen is a Laravel package for a beautiful laravel package for viewing markdown documentation with github-style rendering.
It currently has 0 GitHub stars and 32 downloads on Packagist (latest version v1.0.1).
Install it with composer require smmahfujurrahman/docgen.
Discover more Laravel packages by smmahfujurrahman
or browse all Laravel packages to compare alternatives.
Last updated
A beautiful Laravel package for viewing Markdown documentation with GitHub-style rendering, search functionality, and zero configuration.
Install the package via Composer:
composer require smmahfujurrahman/docgen
The package will automatically register its service provider.
Publish all assets at once:
php artisan vendor:publish --tag=docgen
Or publish specific assets:
# Publish configuration
php artisan vendor:publish --tag=docgen-config
# Publish routes
php artisan vendor:publish --tag=docgen-routes
# Publish views
php artisan vendor:publish --tag=docgen-views
# Publish dummy documentation
php artisan vendor:publish --tag=docgen-docs
Install the package (see above)
Publish the assets:
php artisan vendor:publish --tag=docgen
Access your documentation:
http://your-app.test/documentation
That's it! You'll see the welcome page with dummy documentation.
docs folder in your Laravel project root.md (Markdown) filesExample structure:
docs/
βββ README.md
βββ installation.md
βββ api/
β βββ authentication.md
β βββ endpoints.md
βββ guides/
βββ getting-started.md
βββ deployment.md
After publishing, update your routes/web.php to include the documentation routes:
// At the end of routes/web.php
if (file_exists(base_path('routes/docs.php'))) {
require base_path('routes/docs.php');
}
Or if you want to customize, you can manually define routes using the config:
Route::get('/docs', function () {
// Your custom implementation
});
The configuration file will be published to config/docgen.php:
return [
// Route prefix for documentation (default: 'documentation')
'route_prefix' => env('DOCGEN_ROUTE_PREFIX', 'documentation'),
// Directory where markdown files are stored (default: 'docs')
'docs_path' => env('DOCGEN_DOCS_PATH', 'docs'),
// Auto-register routes (default: true)
'auto_register_routes' => env('DOCGEN_AUTO_ROUTES', true),
// CommonMark configuration
'commonmark' => [
'html_input' => 'allow',
'allow_unsafe_links' => false,
],
];
Add these to your .env file to customize:
DOCGEN_ROUTE_PREFIX=documentation
DOCGEN_DOCS_PATH=docs
DOCGEN_AUTO_ROUTES=true
Publish the views and modify them:
php artisan vendor:publish --tag=docgen-views
Views will be copied to resources/views/documentations/:
docs-index.blade.php - Documentation index pagedocs-viewer.blade.php - Individual document viewerEdit the published views to change colors, fonts, or layout. The views use inline CSS for easy customization.
If you want full control over routes, set auto_register_routes to false in config and define your own routes:
use League\CommonMark\CommonMarkConverter;
Route::get('/my-docs', function () {
// Your custom documentation logic
});
DocGen includes built-in security:
.md files are accessible../ attacksrealpath() for secure path resolutionDocGen supports full Markdown syntax:
# Heading 1
## Heading 2
### Heading 3
**Bold Text**
*Italic Text*
~~Strikethrough~~
[Link](https://example.com)

```php
<?php
echo "Hello, World!";
### Tables
```markdown
| Column 1 | Column 2 |
|----------|----------|
| Data 1 | Data 2 |
Unordered item
Another item
1. Ordered item
2. Another item
> This is a blockquote
Ctrl+K (Windows/Linux) or Cmd+K (Mac)Escape to clear searchPowered by Highlight.js with support for:
To test the package locally before publishing:
composer.json:{
"repositories": [
{
"type": "path",
"url": "./packages/smmahfujurrahman/docgen"
}
]
}
composer require smmahfujurrahman/docgen:@dev
composer test
Please see CHANGELOG for more information on what has changed recently.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)The MIT License (MIT). Please see LICENSE for more information.
S. M. Mahfujur Rahman
If you find this package helpful, please consider:
Made with β€οΈ by S. M. Mahfujur Rahman