1. Go to this page and download the library: Download alexbusu/php-js library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexbusu / php-js example snippets
lexbusu\Phpjs;
// Get the response object
$response = Phpjs::response();
// Add a message to be displayed to the user
$response->message('Your request was successful!');
// Redirect the user to a new page after 2 seconds
$response->redirect('/new-page', ['timeout' => 2]);
// Log some data to the browser console
$response->consoleLog(['some' => 'data']);
// Trigger a custom event
$response->trigger('custom.event', ['foo' => 'bar']);
// Send the response as JSON
header('Content-Type: application/json');
echo json_encode($response);