PHPackages                             rafael079/readability.php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. rafael079/readability.php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rafael079/readability.php
=========================

A PHP port of Readability.js

1.0.2(3y ago)027Apache-2.0HTMLPHP &gt;=7.4.0

Since Feb 10Pushed 2y agoCompare

[ Source](https://github.com/rafael079/readability.php)[ Packagist](https://packagist.org/packages/rafael079/readability.php)[ Docs](https://github.com/rafael079/readability.php)[ RSS](/packages/rafael079-readabilityphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

Readability.php
===============

[](#readabilityphp)

[![Latest Stable Version](https://camo.githubusercontent.com/b577629759df1d5bee5ea081bfad2502720f827ba4162ddb62aff3fc652623d3/68747470733a2f2f706f7365722e707567782e6f72672f6669766566696c746572732f726561646162696c6974792e7068702f762f737461626c65)](https://packagist.org/packages/fivefilters/readability.php) [![Tests](https://github.com/fivefilters/readability.php/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/fivefilters/readability.php/actions/workflows/main.yml)

PHP port of *Mozilla's* **[Readability.js](https://github.com/mozilla/readability)**. Parses html text (usually news and other articles) and returns **title**, **author**, **main image** and **text content** without nav bars, ads, footers, or anything that isn't the main body of the text. Analyzes each node, gives them a score, and determines what's relevant and what can be discarded.

[![Screenshot](https://raw.githubusercontent.com/fivefilters/readability.php/assets/screenshot.png)](https://raw.githubusercontent.com/fivefilters/readability.php/assets/screenshot.png)

The project aim is to be a 1 to 1 port of Mozilla's version and to follow closely all changes introduced there, but there are some major differences on the structure. Most of the code is a 1:1 copy –even the comments were imported– but some functions and structures were adapted to suit better the PHP language.

**Original Developer**: Andres Rey

**Developer/Maintainer**: FiveFilters.org

Code porting
------------

[](#code-porting)

Master branch - Up to date on 26 August 2021, with the exception of a [piece of code](https://github.com/fivefilters/readability.php/commit/1c662465bded2ab3acf3b975a1315c8c45f0bf73#diff-b9b31807b1a39caec18ddc293e9c52931ba8b55191c61e6b77a623d699a599ffR1899) which doesn't produce the same results in PHP for us compard to the JS version. Perhaps there's an error, or some difference in the underlying code that affects this. If you know what's wrong, please feel free to drop us a note or submit a pull request. :)

Version 2.1.0 - Up to date with Readability.js up to [19 Nov 2018](https://github.com/mozilla/readability/commit/876c81f710711ba2afb36dd83889d4c5b4fc2743).

Requirements
------------

[](#requirements)

PHP 7.4+, ext-dom, ext-xml, and ext-mbstring. To install these dependencies (in the rare case your system does not have them already), you could try something like this in \*nix like environments:

`$ sudo apt-get install php7.4-xml php7.4-mbstring`

How to use it
-------------

[](#how-to-use-it)

First you have to require the library using composer:

`composer require fivefilters/readability.php`

Then, create a Readability class and pass a Configuration class, feed the `parse()` function with your HTML and echo the variable:

```
