PHPackages                             nvan/php-babel-transpiler - 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. nvan/php-babel-transpiler

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

nvan/php-babel-transpiler
=========================

NVAN's PHP Babel Transpiler

v1.0(5y ago)6974↓90%MITPHPPHP &gt;=7.4.0

Since Jan 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/nvan/php-babel-transpiler)[ Packagist](https://packagist.org/packages/nvan/php-babel-transpiler)[ RSS](/packages/nvan-php-babel-transpiler/feed)WikiDiscussions master Synced 3w ago

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

NVAN PHP Babel Transpiler
=========================

[](#nvan-php-babel-transpiler)

---

Introduction
------------

[](#introduction)

This small library is made as an easy and clean way to transpile JS with Babel.

This is not a transpiler as is, it's just a way to call the CLI version of Babel.

How to use
----------

[](#how-to-use)

After installing the [dependencies](#dependencies), just use composer to include the library into your project:

```
$ composer require nvan/php-babel-transpiler
```

Then, instance the class passing the folder in which the node modules are placed as the first argument.

Then you can use the functions:

- `transpile` to transpile a script passing a string
- `transpileFile` to transpile a script passing the route to a file

Both functions will return the transpiled code as a string.

**Full example:**

```
