PHPackages                             kovah/laravel-html-meta - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kovah/laravel-html-meta

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

kovah/laravel-html-meta
=======================

A Laravel package to parse meta information from an URL.

v5.0.0(1mo ago)847.9k↑27%1MITPHPPHP ^8.2CI passing

Since Mar 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Kovah/laravel-html-meta)[ Packagist](https://packagist.org/packages/kovah/laravel-html-meta)[ Docs](https://github.com/kovah/laravel-html-meta)[ GitHub Sponsors](https://github.com/sponsors/kovah)[ RSS](/packages/kovah-laravel-html-meta/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (16)Used By (0)

Laravel HTML Meta Package
=========================

[](#laravel-html-meta-package)

[![Laravel Support: v11, v12, v13](https://camo.githubusercontent.com/f150789d18735312e4b05a5c1bf6109e67c23202d70ff97e5e2d47bf19408be3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c253230537570706f72742d7631312532432532307631322532432532307631332d626c7565)](https://camo.githubusercontent.com/f150789d18735312e4b05a5c1bf6109e67c23202d70ff97e5e2d47bf19408be3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c253230537570706f72742d7631312532432532307631322532432532307631332d626c7565) [![PHP Support: 8.2, 8.3, 8.4, 8.5](https://camo.githubusercontent.com/f3cfed155a00d265c988d744db530d65856be910c599a7d95fd646171ab8575f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850253230537570706f72742d382e32253243253230382e33253243253230382e34253243253230382e352d626c7565)](https://camo.githubusercontent.com/f3cfed155a00d265c988d744db530d65856be910c599a7d95fd646171ab8575f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850253230537570706f72742d382e32253243253230382e33253243253230382e34253243253230382e352d626c7565)
[![GitHub release (latest by date)](https://camo.githubusercontent.com/3bb203ccf4e6c09c8c3caf85db364a438de5da9ac4b60c62b551e0f4ac0f7ad8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6b6f7661682f6c61726176656c2d68746d6c2d6d657461)](https://camo.githubusercontent.com/3bb203ccf4e6c09c8c3caf85db364a438de5da9ac4b60c62b551e0f4ac0f7ad8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6b6f7661682f6c61726176656c2d68746d6c2d6d657461) [![GitHub Workflow Status (branch)](https://camo.githubusercontent.com/bdcce73a383430f61fd71be8ef31e071c0a1cee678093db3ebe73f696f95cef1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b6f7661682f6c61726176656c2d68746d6c2d6d6574612f746573742e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473)](https://camo.githubusercontent.com/bdcce73a383430f61fd71be8ef31e071c0a1cee678093db3ebe73f696f95cef1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b6f7661682f6c61726176656c2d68746d6c2d6d6574612f746573742e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473) [![GitHub](https://camo.githubusercontent.com/1b4b33d87babbd9d5784a3628b34a069c2e02e6d65dcca6174967276a2bce9a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6f7661682f6c61726176656c2d68746d6c2d6d657461)](https://camo.githubusercontent.com/1b4b33d87babbd9d5784a3628b34a069c2e02e6d65dcca6174967276a2bce9a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6f7661682f6c61726176656c2d68746d6c2d6d657461)

This package provides a simple helper to retrieve the HTML meta tags of a URL. It properly handles connection and client errors and converts the meta tag contents from the source encoding to UTF-8 if possible.

Installation &amp; Usage
------------------------

[](#installation--usage)

You can install this package via Composer:

```
composer require kovah/laravel-html-meta

```

Laravel automatically detects the package and makes it available in your application.

Usage
-----

[](#usage)

The `HtmlMeta` class is available as a facade and exposes the `forUrl` function. Here is a very basic example.

```
try {
    $metaTags = \Kovah\HtmlMeta\Facades\HtmlMeta::forUrl('https://kovah.de')->getMeta();
} catch (\Kovah\HtmlMeta\Exceptions\InvalidUrlException $e) {
    // the provided URL is invalid
} catch (\Kovah\HtmlMeta\Exceptions\DisallowedIpException $e) {
    // the URL points to a blocked non-public IP address
} catch (\Kovah\HtmlMeta\Exceptions\UnreachableUrlException $e) {
    // the website under this URL is not reachable
}
```

The `$metaTags` variable now contains the following data:

```
[
  "title" => "Kovah.de - Web Development and Photography",
  "generator" => "Hugo 0.58.2",
  "viewport" => "width=device-width, initial-scale=1",
  "description" => "Kovah - Web Development by Kevin Woblick",
  "og:title" => "Kovah.de - Web Development by Kevin Woblick",
  "og:description" => "Kovah - Web Development by Kevin Woblick",
  "og:image" => "'https://kovah.de/kvh_social_1200x630.jpg'",
  "og:url" => "'https://kovah.de/'/",
  "og:site_name" => "Portfolio of Kevin Woblick",
  "twitter:card" => "summary_large_image",
  // ...
];
```

If you want to use the response of the original request made to parse the HTML meta, you can get it with the `getResponse()` method like this:

```
$metaResults = \Kovah\HtmlMeta\Facades\HtmlMeta::forUrl('https://kovah.de');

$response = $metaResults->getResponse(); // Illuminate\Http\Client\Response
$metaTags = $metaResults->getMeta(); // array
$url = $metaResults->getUrl(); // string
```

### Parsing HTML

[](#parsing-html)

As an alternative to fetching HTML from a URL, you might also parse HTML directly:

```
$myHtml = ' ...';
$metaTags = \Kovah\HtmlMeta\Facades\HtmlMeta::fromHtml($myHtml)->getMeta();
```

To improve parsing and fallbacks, you might pass HTTP headers and the URL to the `fromHtml()` method like this:

```
$myUrl = 'https://kovah.de';
$httpHeaders = [
    'content-type' => 'text/html; charset=iso-8859-1',
];
$myHtml = ' ...';
$metaTags = \Kovah\HtmlMeta\Facades\HtmlMeta::fromHtml($myHtml, $httpHeaders, $myUrl)->getMeta();
```

Configuration
-------------

[](#configuration)

By default, the package uses a 10 seconds timeout when trying to fetch the content of the URL. If you want to increase or decrease this timeout, you can publish the HTML Meta configuration.

```
php artisan vendor:publish --provider="Kovah\HtmlMeta\HtmlMetaServiceProvider"

```

The configuration can now be found under `config/html-meta.php`.

### Setting a custom User Agent

[](#setting-a-custom-user-agent)

The package allows you to set one or more custom User Agents which will be used to send the requests. The User Agent(s) you want to use must be specified as an array in the package configuration html-meta.php like this:

```
'user_agents' => [
    'Mozilla/5.0 (Windows NT 6.4) AppleWebKit/537.36.0 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36.0',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) AppleWebKit/…4.1.28 (KHTML, like Gecko) Version/15.2.0 Safari/604.1.28',
    'Mozilla/5.0 (compatible; Googlebot/2.1.0; +http://www.google.com/bot.html)',
]
```

The HTML Meta package will randomly choose one of the User Agents for each request. If you want to use only one User Agent, remove all others from the list:

```
'user_agents' => [
    'Mozilla/5.0 (Windows NT 6.4) AppleWebKit/537.36.0 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36.0'
]
```

### Adding more custom headers

[](#adding-more-custom-headers)

The custom\_headers configuration can contain any headers that should be added to any request, except User-Agent and Accept. It can be either an array of headers, or a pipe-separated string.

```
'custom_headers' => [
    'Accept-Encoding' => 'gzip, deflate',
    'referer' => 'https://example.com',
],
```

If headers are passed as a string, the following format applies: `[header name]=[value]|[header name]=[value]|...`

Note: Pipes inside the headers as a string must be escaped with a backslash.

```
'custom_headers' => 'Accept-Encoding=gzip,deflate|referer=https://example.com'
```

### Adding custom Guzzle client options

[](#adding-custom-guzzle-client-options)

The custom\_options configuration is an advanced feature and can be used to pass custom options to the Guzzle HTTP client. Possible options are documented here:

```
'custom_options' => [
    'allow_redirects' => false,
],
```

### Blocking private IP targets

[](#blocking-private-ip-targets)

If you want to prevent requests to non-public IP addresses, enable the `block_private_ips` option:

```
'block_private_ips' => true,
```

When enabled, the package:

- rejects URLs that already use a non-public IPv4 or IPv6 host directly
- resolves hostname targets before the request is sent
- throws `Kovah\HtmlMeta\Exceptions\DisallowedIpException` if any resolved DNS record points to a non-public IP range

This includes private, loopback, link-local and other reserved IP ranges.

Parsing Details
---------------

[](#parsing-details)

The default parser shipping with this package extracts the meta tags from the HTML. These are the steps it is going through after the packages received a successful response:

- All meta tags with `name` or `property` properties are parsed from the `` section. The keys are converted to lowercase.
- The `` tag is parsed and all excessive white space is removed from the start and the end of it.
- The package checks for a charset, which can be specified as:
    - the HTML charset meta tag (``),
    - the HTTP content-type header (content-type: "text/html; charset=utf-8"),
    - or as the HTML http-equiv="content-type" tag (``) We try to parse the charset in this exact order.
- The value of all parsed meta tags is converted from the source charset (if available) to UTF-8, if it does not match UTF-8. **If the meta tag value cannot be converted, it is replaced by `null`!** The only exception is the title, which will be replaced by the hostname of the URL in case a conversion is not possible.
- HTML entities such as `&#8212;` are converted to the correct characters, in this example `—`.

---

This package is a project by [Kevin Woblick](https://kovah.de) and [Contributors](https://github.com/Kovah/laravel-html-meta/graphs/contributors)

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance89

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 91.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~131 days

Recently: every ~115 days

Total

15

Last Release

55d ago

Major Versions

v1.1.1 → v2.0.02021-05-10

v2.2.0 → v3.0.02024-03-19

v3.0.0 → v4.0.02024-12-19

v4.3.0 → v5.0.02026-03-24

PHP version history (6 changes)v1.0.0PHP ^7.3 | ^8.0

v2.1.0PHP ^7.4 | ^8.0 | ^8.1

v2.2.0PHP ^7.4 | ^8.0 | ^8.1 | ^8.2

v3.0.0PHP ^7.4 | ^8.0 | ^8.1 | ^8.2 | ^8.3

v4.0.0PHP ^8.0

v5.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/97cc4ec017b84d17afbc2fd36d1c7697dc046f37d490a10bde330a1f167b816a?d=identicon)[Kovah](/maintainers/Kovah)

---

Top Contributors

[![Kovah](https://avatars.githubusercontent.com/u/1816101?v=4)](https://github.com/Kovah "Kovah (52 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (1 commits)")

---

Tags

htmllaravellaravel-packagemeta-tagsparserlaravelparserhtmlmeta

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kovah-laravel-html-meta/health.svg)

```
[![Health](https://phpackages.com/badges/kovah-laravel-html-meta/health.svg)](https://phpackages.com/packages/kovah-laravel-html-meta)
```

###  Alternatives

[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[ultrono/laravel-sitemap

Sitemap generator for Laravel 11, 12 and 13

36412.6k6](/packages/ultrono-laravel-sitemap)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)[illuminated/wikipedia-grabber

Wikipedia/MediaWiki Grabber for Laravel.

477.3k](/packages/illuminated-wikipedia-grabber)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
