Download the PHP package alexbusu/php-js without Composer
On this page you can find all versions of the php package alexbusu/php-js. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alexbusu/php-js
More information about alexbusu/php-js
Files in alexbusu/php-js
Package php-js
Short Description Micro-framework which translates PHP-defined actions in browser using jQuery
License MIT
Informations about the package php-js
php-js
A micro-framework for translating PHP-defined actions into browser actions using jQuery. This library allows you to send commands (we call them "triggers") from your PHP backend to your JavaScript frontend.
Installation
The recommended way to install this library is through Composer.
Usage
PHP Backend
First, you need to create a Phpjs response object in your PHP code. You can then add triggers to this object.
JavaScript Frontend
Include the provided JavaScript file in your HTML, along with jQuery.
The jquery.setup.js script will automatically handle JSON responses from AJAX calls and trigger the corresponding events.
For custom triggers, you need to set up your own event handlers.
Built-in Triggers
This library comes with a set of built-in triggers:
doc.Status: Display a message to the user. You need to implement the UI for this yourself.winrd: Redirect the browser to a new URL.winreload: Reload the current page.error.console: Log an error message to the console.warn.console: Log a warning message to the console.table.console: Display tabular data in the console.info.console: Log an informational message to the console.log.console: Log a general message to the console.set-cookie: Set a cookie in the browser.
Custom Triggers
You can define and trigger your own custom events from the PHP backend.
PHP:
JavaScript:
Debugging
You can enable debug mode by passing ['debug' => true] to the Phpjs constructor or the response() method. When debug mode is enabled, exceptions thrown in PHP will be sent to the browser console with a full stack trace.
All versions of php-js with dependencies
ext-json Version *