PHPackages                             mf2/mf2 - 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. mf2/mf2

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

mf2/mf2
=======

A pure, generic microformats2 parser — makes HTML as easy to consume as a JSON API

v0.5.0(4y ago)200296.9k↑12.8%39[13 issues](https://github.com/microformats/php-mf2/issues)[10 PRs](https://github.com/microformats/php-mf2/pulls)20CC0-1.0PHPPHP &gt;=5.6.0CI passing

Since Oct 22Pushed 11mo ago29 watchersCompare

[ Source](https://github.com/microformats/php-mf2)[ Packagist](https://packagist.org/packages/mf2/mf2)[ RSS](/packages/mf2-mf2/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (50)Used By (20)

php-mf2
=======

[](#php-mf2)

[![Latest Stable Version](https://camo.githubusercontent.com/20a897f1a214b3945bd0b8a9179739670e16dcb92f99a2ea27f2f04a40dc15fe/687474703a2f2f706f7365722e707567782e6f72672f6d66322f6d66322f76)](https://packagist.org/packages/mf2/mf2) [![Total Downloads](https://camo.githubusercontent.com/a2ef8985ce34af9ec06b0e6c52b4ccb22ffb8bc79d8ab264883edab1201b66ce/687474703a2f2f706f7365722e707567782e6f72672f6d66322f6d66322f646f776e6c6f616473)](https://packagist.org/packages/mf2/mf2) [![Latest Unstable Version](https://camo.githubusercontent.com/ebc401b4b63b537f75d7b1f4d6fbdfeca17bae58778b4c0c191d070fb0ffe266/687474703a2f2f706f7365722e707567782e6f72672f6d66322f6d66322f762f756e737461626c65)](https://packagist.org/packages/mf2/mf2) [![License](https://camo.githubusercontent.com/2c3edfcad5af06157acd2196df0c5f13887609859dca9cf368c6d4e08d467bff/687474703a2f2f706f7365722e707567782e6f72672f6d66322f6d66322f6c6963656e7365)](https://packagist.org/packages/mf2/mf2) [![PHP Version Require](https://camo.githubusercontent.com/573be842a4a2354989e2986e6ac098edfd5022d3fd52f9e0a273995535c56b9b/687474703a2f2f706f7365722e707567782e6f72672f6d66322f6d66322f726571756972652f706870)](https://packagist.org/packages/mf2/mf2) [![](https://github.com/microformats/php-mf2/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/microformats/php-mf2/actions/workflows/main.yml)

php-mf2 is a pure, generic [microformats-2](http://microformats.org/wiki/microformats-2) parser. It makes HTML as easy to consume as JSON.

Instead of having a hard-coded list of all the different microformats, it follows a set of procedures to handle different property types (e.g. `p-` for plaintext, `u-` for URL, etc). This allows for a very small and maintainable parser.

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

[](#installation)

There are two ways of installing php-mf2. We **highly recommend** installing php-mf2 using [Composer](http://getcomposer.org). The rest of the documentation assumes that you have done so.

To install using Composer, run

```
composer require mf2/mf2

```

If you can’t or don’t want to use Composer, then php-mf2 can be installed the old way by downloading [`/Mf2/Parser.php`](https://raw.githubusercontent.com/microformats/php-mf2/master/Mf2/Parser.php), adding it to your project and requiring it from files you want to call its functions from, like this:

```
