Download the PHP package jeffersongoncalves/laravel-npm-readme without Composer
On this page you can find all versions of the php package jeffersongoncalves/laravel-npm-readme. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeffersongoncalves/laravel-npm-readme
More information about jeffersongoncalves/laravel-npm-readme
Files in jeffersongoncalves/laravel-npm-readme
Package laravel-npm-readme
Short Description A Laravel package that fetches an npm package's README from the registry document, renders the markdown and caches the resulting HTML. The default renderer strips raw HTML; provide your own renderer callable (and sanitize) to keep it. Rendered HTML is untrusted — sanitize it before display.
License MIT
Homepage https://github.com/jeffersongoncalves/laravel-npm-readme
Informations about the package laravel-npm-readme
Laravel npm Readme
Fetch an npm package's README straight from the registry document, render the markdown and cache the resulting HTML. The npm registry ships the README markdown inline in the package document, so there is no extra request beyond the registry call.
This is the npm sibling of jeffersongoncalves/laravel-github-readme.
Installation
Optionally publish the config:
Usage
fetchHtml() returns the rendered HTML, or null when the URL isn't an npm package, the registry has no document, or the package ships no README. Results are cached on the default cache store (npm_readme:{package}) for config('npm-readme.cache_minutes').
NpmReadme::packageFromUrl($url) is also public if you only need the package identifier.
Security
The rendered HTML is untrusted (third-party package READMEs). The default renderer therefore strips raw HTML (html_input = strip), so an embedded <script> cannot become stored XSS.
If you need raw HTML kept, provide your own renderer callable in config/npm-readme.php — the output is then unsafe and you must sanitize it before display, e.g. with jeffersongoncalves/laravel-html-sanitizer:
Configuration
| Key | Default | Description |
|---|---|---|
cache_minutes |
60 |
Minutes the rendered HTML is cached per package. |
registry_url |
https://registry.npmjs.org |
npm registry base URL. |
timeout |
8 |
Registry request timeout in seconds. |
user_agent |
laravel-npm-readme |
User-Agent header for the registry request. |
renderer |
null |
Optional callable(string $markdown): string. When null, an internal CommonMark renderer (GFM + heading permalinks, raw HTML stripped) is used. |
Testing
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-npm-readme with dependencies
guzzlehttp/guzzle Version ^7.8
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
league/commonmark Version ^2.8.2
spatie/laravel-package-tools Version ^1.14