Adi JavaScript Tools for PHP is a set of tools that allows write JavaScript and JQuery sequence directly in PHP, making all necessary conversion from php variables to JavaScript automatically.
Preferred way to install is with Composer.
Install this library using composer:
$ composer require adilab/javascript
require('vendor/autoload.php');
use Adi\JavaScript\JavaScript;
echo JavaScript::alert('Hello world');