PHPackages                             phikhi/url-to-text - 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. phikhi/url-to-text

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

phikhi/url-to-text
==================

Extract texts from an url

v1.0.5(3y ago)014MITPHPPHP ^8.1

Since Mar 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/phikhi/url-to-text)[ Packagist](https://packagist.org/packages/phikhi/url-to-text)[ RSS](/packages/phikhi-url-to-text/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (7)Versions (7)Used By (0)

Url to Text
===========

[](#url-to-text)

> Extract any texts from a distant HTML page 🚧 WORK IN PROGRESS (do not use) 🚧

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

[](#installation)

```
composer require phikhi/url-to-text
```

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

```
use Phikhi\UrlToText\UrlToText;

$text = (new UrlToText())
    ->from('https://phikhi.com')
    ->extract()
    ->toArray();
/*
[
    'lorem ipsum dolor sit amet',
    'non gloriam sine audentes',
    '...'
];
*/

$text = (new UrlToText())
    ->from('https://phikhi.com')
    ->extract()
    ->toJson();
// ['lorem ipsum dolor sit amet', 'non gloriam sine audentes', '...'];

$text = (new UrlToText())
    ->from('https://phikhi.com')
    ->extract()
    ->toText();
/*
lorem ipsum dolor sit amet
non gloriam sine audentes
...
*/
```

### Advanced usage

[](#advanced-usage)

You can customize the tags you want to parse

```
$text = (new UrlToText())
    ->from('https://phikhi.com')
    ->allow(['div', 'span']) // will add these tags to the existing allowed tags array (H*, p, li, a).
    ->extract()
    ->toArray();
```

If you want to overwrite the allowed tags array instead of extending it, you can pass a second parameter to the `allow()` method

```
$text = (new UrlToText())
    ->from('https://phikhi.com')
    ->allow(['div', 'span'], overwrite: true) // will replace the existing allowed tags array with this one.
    ->extract()
    ->toArray();
```

By default, `script` and `style` tags are automatically stripped before extracting the allowed tags from the DOM, to prevent some weird behavior during extraction. But you can still customize them if you need with the `deny()` method.

```
$text = (new UrlToText())
    ->from('https://phikhi.com')
    ->deny(['svg']) // will add the `svg` tag to the existing denied tags array (script, style).
    ->extract()
    ->toArray();
```

If you want to overwrite the denied tags array instead of extending it, you can pass a second parameter to the `deny()` method

```
$text = (new UrlToText())
    ->from('https://phikhi.com')
    ->deny(['svg'], overwrite: true) // will replace the existing denied tags array with this one.
    ->extract()
    ->toArray();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~0 days

Total

6

Last Release

1166d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c934d50687620397b0f6cc180a078544070ed64f83864f49ff0225ce8f909de?d=identicon)[phikhi](/maintainers/phikhi)

---

Top Contributors

[![phikhi](https://avatars.githubusercontent.com/u/3796408?v=4)](https://github.com/phikhi "phikhi (17 commits)")

---

Tags

urlparserdomtextextract

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phikhi-url-to-text/health.svg)

```
[![Health](https://phpackages.com/badges/phikhi-url-to-text/health.svg)](https://phpackages.com/packages/phikhi-url-to-text)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

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

An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.

2.4k7.9M123](/packages/paquettg-php-html-parser)[sunra/php-simple-html-dom-parser

Composer adaptation of: A HTML DOM parser written in PHP5+ let you manipulate HTML in a very easy way! Require PHP 5+. Supports invalid HTML. Find tags on an HTML page with selectors just like jQuery. Extract contents from HTML in a single line.

1.3k9.4M62](/packages/sunra-php-simple-html-dom-parser)[vstelmakh/url-highlight

Library to parse urls from string input

102849.1k9](/packages/vstelmakh-url-highlight)[simplehtmldom/simplehtmldom

A fast, simple and reliable HTML document parser for PHP.

1921.3M14](/packages/simplehtmldom-simplehtmldom)[scotteh/php-dom-wrapper

Simple DOM wrapper to select nodes using either CSS or XPath expressions and manipulate results quickly and easily.

1471.9M10](/packages/scotteh-php-dom-wrapper)

PHPackages © 2026

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