PHPackages                             xparse/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. xparse/parser

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

xparse/parser
=============

Parser client

3.0.0(1y ago)241.4k↓11.5%71MITPHPPHP ^8.2CI passing

Since Dec 26Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/xparse/Parser)[ Packagist](https://packagist.org/packages/xparse/parser)[ Docs](https://github.com/xparse/Parser)[ RSS](/packages/xparse-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (28)Used By (1)

Parser
======

[](#parser)

[![GitHub tag](https://camo.githubusercontent.com/f109b5a0ece1fc200fffbb6895f83e3b45a1d3b5efe346f13df6126766ef34ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f7870617273652f5061727365722e7376673f7374796c653d666c61742d737175617265)](https://github.com/xparse/Parser/tags)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Coverage Status](https://camo.githubusercontent.com/cb4e3c7584490436c9e349c19864f2181e20450d9469f5affb85177e16d9dd70/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7870617273652f5061727365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/xparse/Parser/code-structure)[![Quality Score](https://camo.githubusercontent.com/73e1d35fa9c456e7e1ee3cf230c2aeb26b9b823246d5e7a46478efc64e78922b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7870617273652f5061727365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/xparse/Parser)[![Total Downloads](https://camo.githubusercontent.com/4ed25f102a9b03cd1449b27924cc53fb387ea50f5c2c4f72f7dbb1d589544d0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7870617273652f7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xparse/parser)

Parser client

Install
-------

[](#install)

Via Composer

```
$ composer require xparse/parser
```

Usage
-----

[](#usage)

```
  $parser = new \Xparse\Parser\Parser();
  $title = $parser->get('http://funivan.com')->content('//*[@class="entry-title"]/a');
  print_r($title);
```

Using with custom Middleware
----------------------------

[](#using-with-custom-middleware)

If you are using custom Guzzle Middleware and it doesn't send real requests, in order to get last effective url you need to set it to response `X-GUZZLE-EFFECTIVE-URL` header manually.

Here is an example of `__invoke()` method in your custom Middleware

```
  public function __invoke(callable $handler) : \Closure {
    return function (RequestInterface $request, array $options) use ($handler) {

      # some code

      return $handler($request, $options)->then(function (ResponseInterface $response) use ($request) {

        $response = $response->withHeader('X-GUZZLE-EFFECTIVE-URL', $request->getUri());

        # some code

        return $response;
      });
    };
  }
```

Recursive Parser
================

[](#recursive-parser)

Recursive Parser allows you to parse website pages recursively. You need to pass link from where to start and set next page expression (xPath, css, etc).

Basic Usage
-----------

[](#basic-usage)

Try to find all links to the repositories on github. Our query will be `xparse`. With recursive pagination we can traverse all pagination links and process each resulting page to fetch repositories links.

```
  use Xparse\Parser\Parser;
  use Xparse\Parser\RecursiveParser;

  # init Parser
  $parser = new Parser();

  # set expression to pagination links and initial page url
  $pages = new RecursiveParser(
       $parser,
       ["//*[@class='pagination']//a/@href"],
       ['https://github.com/search?q=xparse']
  );

  $allLinks = [];
  foreach($pages as $page){
    # set expression to fetch repository links
    $adsList = $page->value("//*[@class='repo-list-name']//a/@href")->all();
    # merge and remove duplicates
    $allLinks = array_values(array_unique(array_merge($allLinks, $adsList)));
  }
  print_r($allLinks);
```

Testing
-------

[](#testing)

```
    ./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/xparse/Parser/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [funivan](https://github.com/funivan)
- [All Contributors](https://github.com/xparse/Parser/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance63

Regular maintenance activity

Popularity33

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~184 days

Recently: every ~345 days

Total

21

Last Release

464d ago

Major Versions

0.5.0-alpha → 1.0.02021-05-31

1.0.1 → 2.0.02024-01-11

2.0.0 → 3.0.02025-02-08

PHP version history (8 changes)0.0.1PHP &gt;=5.3.0

0.0.2PHP &gt;=5.5.0

0.0.4PHP &gt;=5.6.0

0.2.0PHP ^7.0

0.4.0PHP ^7.1

0.5.0-alphaPHP ^7.3 || ^8.0

2.0.0PHP ^8.1

3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ee14f8f97b3ead4c91823e410ea170293b55be64adf12a20d965f19008839a6?d=identicon)[funivan](/maintainers/funivan)

---

Top Contributors

[![funivan](https://avatars.githubusercontent.com/u/425208?v=4)](https://github.com/funivan "funivan (80 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (35 commits)")[![ganchclub](https://avatars.githubusercontent.com/u/7393570?v=4)](https://github.com/ganchclub "ganchclub (23 commits)")[![ChrisGalliano](https://avatars.githubusercontent.com/u/17964229?v=4)](https://github.com/ChrisGalliano "ChrisGalliano (11 commits)")[![saintdron](https://avatars.githubusercontent.com/u/23000680?v=4)](https://github.com/saintdron "saintdron (10 commits)")[![SergeiMV](https://avatars.githubusercontent.com/u/92272880?v=4)](https://github.com/SergeiMV "SergeiMV (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (2 commits)")[![maxKuk](https://avatars.githubusercontent.com/u/25341044?v=4)](https://github.com/maxKuk "maxKuk (1 commits)")

---

Tags

parsergrabber

###  Code Quality

TestsPHPUnit

Static AnalysisRector

Code StyleECS

### Embed Badge

![Health badge](/badges/xparse-parser/health.svg)

```
[![Health](https://phpackages.com/badges/xparse-parser/health.svg)](https://phpackages.com/packages/xparse-parser)
```

###  Alternatives

[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)[illuminated/wikipedia-grabber

Wikipedia/MediaWiki Grabber for Laravel.

477.3k](/packages/illuminated-wikipedia-grabber)

PHPackages © 2026

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