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

1.0.1 2019-01-16 14:46 UTC

This package is auto-updated.

Last update: 2024-05-16 13:56:05 UTC


Latest Stable Version Build Status StyleCI Test Coverage Code Climate

PHP wrapper to execute coffee-script node package or fallback to a PHP alternative.


First you need composer if you have not already. Then get the package with composer require nodejs-php-fallback/coffeescript then require the composer autload in your PHP file if it's not already:


use NodejsPhpFallback\CoffeeScript;

// Require the composer autload in your PHP file if it's not already.
// You do not need to if you use a framework with composer like Symfony, Laravel, etc.
require 'vendor/autoload.php';

$coffee = new CoffeeScript('path/to/');

// Output to a file:

// Get JS contents:
$jsContents = $coffee->getResult();

// Output to the browser:
header('Content-type: text/javascript');
echo $coffee;

// You can also get Coffee-Script code from a string:
$coffee = new CoffeeScript('
alert "Foo"
// Then write JS with:
// or get it with:
$jsContents = $coffee->getResult();

// Pass false to the CoffeeScript constructor to wrap the rendered JS in a function, (else, the bare option is used):
$coffee = new CoffeeScript('path/to/', false);

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.