PHPackages                             codealfa/css2xpath - 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. codealfa/css2xpath

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

codealfa/css2xpath
==================

CSS to XPath Converter

1.0(1y ago)04GPL-3.0-or-laterPHPPHP &gt;=8.0

Since Sep 30Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/codealfa/css2xpath)[ Packagist](https://packagist.org/packages/codealfa/css2xpath)[ RSS](/packages/codealfa-css2xpath/feed)WikiDiscussions main Synced 2w ago

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

CSS to XPath Converter
======================

[](#css-to-xpath-converter)

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

[](#installation)

Run the following command to use the library in your projects.

```
composer require codealfa/css2xpath

```

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

[](#basic-usage)

```
use CodeAlfa\Css2Xpath\Css2XpathConverter;
use CodeAlfa\Css2Xpath\SelectorFactory;

$converter = new Css2XpathConverter(new SelectorFactory());
$xPath = $converter->convert('p#main, div.container');
var_dump($xPath);
```

Output:

```
p[@id="main"]|div[@class and contains(concat(" ", normalize-space(@class), " "), " container ")]

```

Notes
-----

[](#notes)

- The Selector classes are extendable if you need to add or change functionality. You'll just need to create your own `SelectorFactory` or extend the existing one to inject into the `Css2XpathConverter` class.
- Some CSS pseudo-selectors only make sense in the context of a web browser, so only the following pseudo-selectors are implemented. All others are ignored:
    - :enabled
    - :disabled
    - :read-only
    - :read-write
    - :checked
    - :required
    - :root
    - :empty
    - :first-child
    - :last-child
    - :only-child
    - :first-of-type
    - :last-of-type
    - :only-of-type
    - :not
    - :has

License
-------

[](#license)

GPL-3.0 or later

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance48

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

687d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10180134?v=4)[Samuel Marshall](/maintainers/codealfa)[@codealfa](https://github.com/codealfa)

---

Top Contributors

[![codealfa](https://avatars.githubusercontent.com/u/10180134?v=4)](https://github.com/codealfa "codealfa (36 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codealfa-css2xpath/health.svg)

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

###  Alternatives

[alperenersoy/filament-export

Customizable export and print functionality for Filament Admin Panel

273357.9k2](/packages/alperenersoy-filament-export)[duncan3dc/bom-string

A small PHP library to handle byte order marks (BOM)

15590.7k2](/packages/duncan3dc-bom-string)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

12287.4k](/packages/datomatic-nova-detached-actions)[zephir/kirby-cookieconsent

Kirby cookieconsent plugin

515.7k](/packages/zephir-kirby-cookieconsent)

PHPackages © 2026

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