PHPackages                             js-transformer/js-transformer - 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. js-transformer/js-transformer

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

js-transformer/js-transformer
=============================

Call any js-transformer package through PHP

1.0.0(8y ago)5263.9k↓28.1%1MITPHP

Since Oct 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/kylekatarnls/js-transformer-php-wrap)[ Packagist](https://packagist.org/packages/js-transformer/js-transformer)[ Docs](https://github.com/kylekatarnls/js-transformer-php-wrap)[ RSS](/packages/js-transformer-js-transformer/feed)WikiDiscussions master Synced 1mo ago

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

js-transformer for PHP
======================

[](#js-transformer-for-php)

PHP wrapper to call any js-transformer package

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

[](#installation)

First, install `js-transformer` with [composer](http://getcomposer.org/):

```
composer require js-transformer/js-transformer
```

Then add the following the jstransformer packages in the `extra.npm` section of your `composer.json` file (if you had not yet, the previous command should have created it at current directory opened in your terminal).

So for example if you want to use stylus and less transformers, add the following:

```
"extra": {
  "npm": {
    "jstransformer-stylus": "^1.4.0",
    "jstransformer-less": "^2.6.0"
  }
}
```

As you can see, you can use any [semantic versioning](https://docs.npmjs.com/misc/semver)as in npm or composer dependencies to specify which package version to use.

Then use:

```
composer install
```

to install npm packages via composer.

Usage
-----

[](#usage)

### Call a transformer

[](#call-a-transformer)

```
$transformer = new JsTransformer();

$lessCode = '
a {
  .foo {
    color: red;
  }
}
';

echo $transformer->call('jstransformer-less', array($lessCode));
```

will display:

```
a .foo {
  color: red;
}
```

And you can pass options, locals or as many arguments as the js-transformer can take:

```
$transformer = new JsTransformer();

$lessCode = '
a {
  .foo {
    color: red;
  }
}
';

$options = array(
  'compress' => true,
);

echo $transformer->call('jstransformer-less', array($lessCode, $options));
```

will display:

```
a .foo{color: red}
```

### Check if a transformer is installed

[](#check-if-a-transformer-is-installed)

```
$transformer = new JsTransformer();

if ($transformer->isInstalled('jstransformer-less')) {
  echo 'Less transformer is installed.';
} else {
  echo 'You need to install less transformer to use this package.';
}
```

### Get node engine

[](#get-node-engine)

This package use [nodejs-php-fallback](https://github.com/kylekatarnls/nodejs-php-fallback)to install and execute node packages.

If you need it, you can get the nodejs-php-fallback instance:

```
if (!$transformer->getNodeEngine()->isNodeInstalled()) {
  echo 'nodejs should be installed for js-transformer to work.';
}
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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

Unknown

Total

1

Last Release

3125d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/df90c422f521bf26355c3e185a59fe7afb35531af56244dfaec03ee1d0ca6f24?d=identicon)[kylekatarn](/maintainers/kylekatarn)

---

Top Contributors

[![kylekatarnls](https://avatars.githubusercontent.com/u/5966783?v=4)](https://github.com/kylekatarnls "kylekatarnls (8 commits)")

---

Tags

js-transformer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/js-transformer-js-transformer/health.svg)

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

###  Alternatives

[nodejs-php-fallback/uglify

PHP wrapper to execute uglify-js/clean-css node package or fallback to PHP alternatives

17143.4k3](/packages/nodejs-php-fallback-uglify)[nodejs-php-fallback/stylus

PHP wrapper to execute stylus node package or fallback to a PHP alternative

11135.5k4](/packages/nodejs-php-fallback-stylus)[airesvsg/acf-to-rest-api-recursive

Get ACF fields recursively

442.5k](/packages/airesvsg-acf-to-rest-api-recursive)

PHPackages © 2026

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