PHPackages                             js-phpize/js-phpize - 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-phpize/js-phpize

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

js-phpize/js-phpize
===================

Convert js-like syntax to standalone PHP code.

2.9.2(8mo ago)23417.5k↓56.8%32MITPHPPHP &gt;=7.0CI passing

Since Aug 14Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/pug-php/js-phpize)[ Packagist](https://packagist.org/packages/js-phpize/js-phpize)[ GitHub Sponsors](https://github.com/kylekatarnls)[ Fund](https://opencollective.com/pug-php)[ RSS](/packages/js-phpize-js-phpize/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (1)Versions (75)Used By (2)

JsPhpize
========

[](#jsphpize)

[![Latest Stable Version](https://camo.githubusercontent.com/d54b48700f0060141ae3ee0b6ef7031365b518c2235541db52b9be88178c4d43/68747470733a2f2f706f7365722e707567782e6f72672f6a732d706870697a652f6a732d706870697a652f762f737461626c652e706e67)](https://packagist.org/packages/js-phpize/js-phpize)[![Build Status](https://camo.githubusercontent.com/03b22ec7ed9b6b819f093454d3c86bb44b3192faa91ab8925b74e81756527b20/68747470733a2f2f7472617669732d63692e6f72672f7075672d7068702f6a732d706870697a652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pug-php/js-phpize)[![StyleCI](https://camo.githubusercontent.com/750078f1024d63c47a43563188adafaa8383b1ebd36c20ec68f9cdc2128a0ba7/68747470733a2f2f7374796c6563692e696f2f7265706f732f36353637303433362f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/65670436)[![Test Coverage](https://camo.githubusercontent.com/bb8f81a3ccf507e4bf4df88e85bb3681f238d5b254c0340e1f089066159933f8/68747470733a2f2f636f6465636f762e696f2f67682f7075672d7068702f6a732d706870697a652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/pug-php/js-phpize)[![Code Climate](https://camo.githubusercontent.com/2dfa64e3b9d4bde8f4b3900000d3fe0256d9a9d188c34252d720b6cc4e3586f3/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7075672d7068702f6a732d706870697a652f6261646765732f6770612e737667)](https://codeclimate.com/github/pug-php/js-phpize)

Convert js-like syntax to standalone PHP code.

Install
-------

[](#install)

In the root directory of your project, open a terminal and enter:

```
composer require js-phpize/js-phpize
```

Usage
-----

[](#usage)

Use compile to get PHP equivalent code to JavaScript input:

```
use JsPhpize\JsPhpize;

$jsPhpize = new JsPhpize();

echo $jsPhpize->compile('foo = { bar: { "baz": "hello" } }');
```

This code will output the following PHP code:

```
$foo = array( "bar" => array( "baz" => "hello" ) );
```

Or use render to execute it directly:

```
use JsPhpize\JsPhpize;

$jsPhpize = new JsPhpize();

$code = '
    // Create an object
    foo = { bar: { "baz": "hello" } };
    key = 'bar'; // instanciate a string

    return foo[key].baz;
';

$value = $jsPhpize->render($code);

echo $value;
```

This will display `hello`.

This library intend to is intended to allow js-like in PHP contexts (such as in template engines).

See the [Phug documentation](https://www.phug-lang.com/#js-style-expressions)to see an implementation example as Pug expressions PHP converter.

And also check [examples](https://github.com/pug-php/js-phpize/tree/master/examples)to see more examples (**.js** files are input examples **js-phpize** can handle and either **.return** show you what the engine will return for this code, or **.php** show you how it's compiled into PHP).

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance59

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 99.2% 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 ~47 days

Recently: every ~492 days

Total

73

Last Release

257d ago

Major Versions

0.2.4 → 1.0.02016-11-30

1.14.0 → 2.0.02018-06-10

PHP version history (2 changes)0.1.0PHP &gt;=5.3.0

2.0.0PHP &gt;=7.0

### 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 (245 commits)")[![gBokiau](https://avatars.githubusercontent.com/u/108301?v=4)](https://github.com/gBokiau "gBokiau (1 commits)")[![SagePtr](https://avatars.githubusercontent.com/u/3179266?v=4)](https://github.com/SagePtr "SagePtr (1 commits)")

---

Tags

convert-jsphptranspiler

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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