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

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

scarlett/lshw-parser
====================

A simple php lshw parser with no non ext dependencies.

1.0.3(1y ago)06MITPHPPHP ^8.2

Since Jul 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ScarlettSamantha/lshw-parser)[ Packagist](https://packagist.org/packages/scarlett/lshw-parser)[ Docs](https://scarlettbytes.nl/lshw-parser)[ RSS](/packages/scarlett-lshw-parser/feed)WikiDiscussions main Synced today

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

LSHW XML Parser
===============

[](#lshw-xml-parser)

This PHP library parses XML output from the lshw command to extract hardware information on Linux systems.

Features
--------

[](#features)

- Parse lshw XML output.
- Retrieve system memory, CPU, storage device, and network interface information.
- Dynamic filtering of nodes based on properties.
- Customizable filtering logic with callable functions.
- Skiphubs can be enabled to skip hub/bridge objects.
- &gt;85% code coverage.

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

[](#installation)

Install the library using Composer:

`sh composer require scarlett/lshw-parser`

Usage
-----

[](#usage)

Parsing the XML Output

```
use Scarlett\LshwParser\Parser;

$xmlContent = file_get_contents('path/to/lshw-output.xml');
$parser = new Parser($xmlContent);

// Get system memory information
$memory = $parser->getSystemMemory();
echo $memory->getProperty('description')->getFirstValue();

// Get CPU information
$cpuInfo = $parser->getCpuInfo();
echo $cpuInfo->getProperty('vendor')->getFirstValue();
```

Filtering Nodes by Properties

```
use Scarlett\LshwParser\Parser;

$xmlContent = file_get_contents('path/to/lshw-output.xml');
$parser = new Parser($xmlContent);

// Filter nodes with AND logic
$results = $parser->parseByProperties(['class' => 'processor', 'vendor' => 'Intel Corp.'], 'and');
foreach ($results as $result) {
    echo $result->getProperty('description')->getFirstValue();
}

// Filter nodes with OR logic
$results = $parser->parseByProperties(['class' => 'processor', 'vendor' => 'AMD'], 'or');
foreach ($results as $result) {
    echo $result->getProperty('description')->getFirstValue();
}
```

Custom Filtering with Callables

```
use Scarlett\LshwParser\Parser;

$xmlContent = file_get_contents('path/to/lshw-output.xml');
$parser = new Parser($xmlContent);

$results = $parser->searchNodesByFilter(function($properties) {
    return isset($properties['vendor']) && $properties['vendor'] === 'Intel Corp.';
});

foreach ($results as $result) {
    echo $result->getProperty('description')->getFirstValue();
}
```

Skiphubs
--------

[](#skiphubs)

The skipHubs feature(`default:OFF`) in the Parser class allows for the skipping of nodes identified as hubs during parsing. The following regex patterns are used to match node descriptions:

- `/usb\s*(hub|2(\.0)?\s*hub|3(\.0)?\s*hub)/i`: Matches "usb hub", "usb2 hub", "usb2.0 hub", "usb3 hub", "usb3.0 hub".
- `/(pci(e)?\s*bridge)/i`: Matches "pci bridge", "pcie bridge".
- `/(isa\s*bridge)/i`: Matches "isa bridge".
- `/hub/i`: Matches "hub".

Setting the skipHubs flag to true enables this functionality, ensuring that such nodes are excluded from the results. To enable `public function __construct(string $xmlContent, bool $skipHubs = true)` or when instanced `setSkipHubs(bool) -> void`.

Running Tests
-------------

[](#running-tests)

The project uses PHPUnit for unit testing. To run the tests, use the following command:

`./vendor/bin/phpunit .`

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

[](#contributing)

Contributions are welcome! Please open an issue or submit a pull request for any changes.

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Total

3

Last Release

701d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33827053?v=4)[Scarlett Samantha Verheul ](/maintainers/ScarlettSamantha)[@ScarlettSamantha](https://github.com/ScarlettSamantha)

---

Top Contributors

[![ScarlettSamantha](https://avatars.githubusercontent.com/u/33827053?v=4)](https://github.com/ScarlettSamantha "ScarlettSamantha (3 commits)")

---

Tags

linuxlshwphp8system-infoxmlphpparserlinuxubuntuinformationphp8hardwarelshw

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k959.4M159](/packages/doctrine-lexer)[simplehtmldom/simplehtmldom

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

1931.4M15](/packages/simplehtmldom-simplehtmldom)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23796.2k2](/packages/corveda-php-sandbox)[butschster/proto-parser

Proto parser is a library for parsing Protocol Buffers files into AST

591.3k](/packages/butschster-proto-parser)[leonelquinteros/php-toml

PHP parser for TOML language ( https://github.com/toml-lang/toml )

286.9k](/packages/leonelquinteros-php-toml)

PHPackages © 2026

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