PHPackages                             lukaswhite/php-meta-tags-parser - 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. lukaswhite/php-meta-tags-parser

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

lukaswhite/php-meta-tags-parser
===============================

A PHP package for parsing meta tags in HTML documents

0.0.1(4y ago)0487MITPHP

Since Dec 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lukaswhite/php-meta-tags-parser)[ Packagist](https://packagist.org/packages/lukaswhite/php-meta-tags-parser)[ RSS](/packages/lukaswhite-php-meta-tags-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

PHP Meta Tags Parser
====================

[](#php-meta-tags-parser)

Extracts metadata (title, description, Open Graph etc) from the content of a web page.

Note that this library simply deals with raw HTML, rather than try to tie you down to one particular method for retrieving the content of an external URL. (I usually use Guzzle, but to make it a dependency might cause difficulties in terms of versioning.)

Installation
------------

[](#installation)

```
composer require lukaswhite/php-meta-tags-parser
```

Usage
-----

[](#usage)

```
use Lukaswhite\MetaTagsParser\Parser;

$html = '...';

$parser = new Parser();
$result = $parser->parse($html);
```

### Using the result

[](#using-the-result)

The `parse()` method returns an object that encapsulates any page data it's extracted from the provided HTML.

```
$result->getTitle();
$result->getDescription();
$result->getKeywords();
$result->getUrl();
$result->getFacebookAppId();

$result->openGraph()->getSiteName();
$result->openGraph()->getType();
$result->openGraph()->getTitle();
$result->openGraph()->getDescription();
$result->openGraph()->getLocale();
$result->openGraph()->getImages(); // returns an array of URLs
$result->openGraph()->getLatitude();
$result->openGraph()->getLongitude();
$result->openGraph()->getAltitude();

$result->toArray(); // all of the extracted metadata
```

It will also extract RSS and/or Atom feeds; `getFeeds()` returns an array of instances of the `Feed` class:

```
$feed->getType(); // Feed::RSS or Feed::ATOM
$feed->isRSS();
$feed->isAtom();
$feed->getUri();
$feed->getTitle();
```

The `getFeeds()` method accepts an optional `$type` argument, to choose one or the other:

```
$result->getFeeds(Feed::RSS);
// or
$result->getFeeds(Feed::ATOM);
```

Cleansing the data
------------------

[](#cleansing-the-data)

The package ships with a very simple string cleanser; essentially it just decodes any HTML entities. You're free to provide your own cleanser; just implement the `CleansesStrings` interface, and provide an instance to the parser's constructor. It simply needs to provide a `run()` method, that accepts a string and returns the cleansed version.

Sanitizing the data
-------------------

[](#sanitizing-the-data)

The package ships with a very simple string sanitzer; under the hood it simply uses the `strip_tags()` function. If you wish to provide your own sanitizer, just implement the `SanitizesStrings` interface, and provide an instance to the parser's constructor. It simply needs to provide a `run()` method, that accepts a string and returns the sanitized version.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1626d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1bd633ffdf0f66a73a288c4edcacfa43d214cd95a53384c6fe5ea4b3554dd9d?d=identicon)[lukaswhite](/maintainers/lukaswhite)

---

Top Contributors

[![lukaswhite](https://avatars.githubusercontent.com/u/999014?v=4)](https://github.com/lukaswhite "lukaswhite (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lukaswhite-php-meta-tags-parser/health.svg)

```
[![Health](https://phpackages.com/badges/lukaswhite-php-meta-tags-parser/health.svg)](https://phpackages.com/packages/lukaswhite-php-meta-tags-parser)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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