PHPackages                             prestashop/rtlcss-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. prestashop/rtlcss-php

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

prestashop/rtlcss-php
=====================

Converts CSS to Right-to-Left

v2.0.0(8y ago)31621MITPHPPHP &gt;=5.4

Since Jul 28Pushed 8y agoCompare

[ Source](https://github.com/PrestaShop/rtlcss-php)[ Packagist](https://packagist.org/packages/prestashop/rtlcss-php)[ RSS](/packages/prestashop-rtlcss-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

RtlCss
------

[](#rtlcss)

RtlCss is a library for converting Left-To-Right (LTR) Cascading Style Sheets(CSS) to Right-To-Left (RTL).

Usage
-----

[](#usage)

### Installation using composer

[](#installation-using-composer)

Add the library to your composer.json

```
{
    "require": {
        "prestashop/rtlcss-php": "*"
    }
}
```

### Flipping

[](#flipping)

```
$parser = new Sabberworm\CSS\Parser($css);
$tree = $parser->parse()
$rtlcss = new PrestaShop\RtlCss\RtlCss($tree);
$rtlcss->flip();
echo $tree->render();
```

For parsing options and rendering, refer to [PrestaShop/PHP-CSS-Parser](https://github.com/PrestaShop/PHP-CSS-Parser).

Output sample
-------------

[](#output-sample)

```
.div {
    direction: ltr;
    left: 10px;
    border: 10px 5px 0px 2px;
    float: left;
}
```

Becomes:

```
.div {
    direction: rtl;
    right: 10px;
    border: 10px 2px 0px 5px;
    float: right;
}
```

Options
-------

[](#options)

You can prefix your CSS with comments starting with `/*rtl:*/` for special handling.

### Do not flip values

[](#do-not-flip-values)

Prepend with `/*rtl:ignore*/`, or wrap within `/*rtl:begin:ignore*/` and `/*rtl:end:ignore*/`.

```
.div {
    /*rtl:ignore*/
    float: left;
    left: 10px;
}
.div {
    direction: ltr;
    /*rtl:begin:ignore*/
    float: left;
    left: 10px;
    /*rtl:end:ignore*/
}
```

Becomes:

```
.div {
    float: left;
    right: 10px;
}
.div {
    direction: rtl;
    float: left;
    left: 10px;
}
```

### Remove CSS

[](#remove-css)

Prepend with `/*rtl:remove*/`, wrap within `/*rtl:begin:remove*/` and `/*rtl:end:remove*/`.

```
.div {
    /*rtl:remove*/
    float: left;
    left: 10px;
}
.div {
    direction: ltr;
    /*rtl:begin:remove*/
    float: left;
    left: 10px;
    /*rtl:end:remove*/
}
```

Becomes:

```
.div {
    right: 10px;
}
.div {
    direction: rtl;
}
```

### Additional CSS

[](#additional-css)

Write the CSS in a content starting with `/*rtl:raw:`.

```
.div {
    /*rtl:raw:
        text-align: left;
    */
    float: left;
}
```

Becomes:

```
.div {
    text-align: left;
    float: right;
}
```

### Limitation

[](#limitation)

Currently the comments must always precede a statement, they will not work if they are not followed by anything.

Valid:

```
.div {
    /*rtl:raw:
        text-align: left;
    */
    float: left;
}
```

Invalid:

```
.div {
    float: left;
    /*rtl:raw:
        text-align: left;
    */
}
```

CSS support
-----------

[](#css-support)

A lot of common CSS rules are supported, however a few complex ones are not. To get a grasp of what is supported and what isn't, please refer to the test cases. Unsupported scenarios are marked to be skipped.

About this tool
---------------

[](#about-this-tool)

This tool is very heavily inspired by [MohammadYounes/rtlcss](https://github.com/MohammadYounes/rtlcss), even though at this stage it does not include all of its features. See this library as a partial port of the latter.

Credits
-------

[](#credits)

- [moodlehq/rtlcss-php](https://github.com/moodlehq/rtlcss-php) Original work
- [MohammadYounes/rtlcss](https://github.com/MohammadYounes/rtlcss) for being the example we followed.
- [cssjanus/php-cssjanus](https://github.com/cssjanus/php-cssjanus/) for providing additional test cases.
- [Sabberworm/PHP-CSS-Parser](https://github.com/sabberworm/PHP-CSS-Parser) for parsing CSS in PHP.

License
-------

[](#license)

Licensed under the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

2

Last Release

3059d ago

Major Versions

v1.0.0 → v2.0.02017-12-28

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15106407?v=4)[Jarvis](/maintainers/ps-jarvis)[@ps-jarvis](https://github.com/ps-jarvis)

---

Top Contributors

[![eternoendless](https://avatars.githubusercontent.com/u/1009343?v=4)](https://github.com/eternoendless "eternoendless (18 commits)")

---

Tags

css-processorlibraryrtlcssrtl

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/prestashop-rtlcss-php/health.svg)

```
[![Health](https://phpackages.com/badges/prestashop-rtlcss-php/health.svg)](https://phpackages.com/packages/prestashop-rtlcss-php)
```

###  Alternatives

[components/flag-icon-css

A curated collection of all country flags in SVG — plus the CSS for easier integration.

12.0k1.6M23](/packages/components-flag-icon-css)[matthiasmullie/minify

CSS &amp; JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.

2.0k30.5M336](/packages/matthiasmullie-minify)[scssphp/scssphp

scssphp is a compiler for SCSS written in PHP.

62827.7M220](/packages/scssphp-scssphp)[mexitek/phpcolors

A series of methods that let you manipulate colors. Just incase you ever need different shades of one color on the fly.

5003.6M18](/packages/mexitek-phpcolors)[wikimedia/less.php

PHP port of the LESS processor

12327.4M77](/packages/wikimedia-lessphp)[cerdic/css-tidy

CSSTidy is a CSS minifier

2092.0M6](/packages/cerdic-css-tidy)

PHPackages © 2026

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