Ratings | | Unique User Downloads | | Download Rankings |
80% | | Total: 585 This week: 1 | | All time: 5,283 This week: 350 |
|
Description | | Authors Jared White J. Max Wilson Joseph Woolley Steffen Konerow Thierry Feuzeu
Contributor
|
This package can call PHP classes from JavaScript using AJAX.
It can register objects of classes or global functions and process AJAX requests that are handled by the registered functions.
The package can register directories of classes, so it is not necessary to register each class in each directory at once, with support to namespaces.
The classes are autoloaded on demand, so only the classes that necessary for each AJAX request will be loaded.
The AJAX calls are done by a separate JavaScript library which can eventually be retrieved from a CDN (Content Delivery Networt) so it does not have to be installed by this package. Innovation Award
July 2016
Number 2
Prize: One downloadable copy of Komodo IDE |
Many Web applications have browser side (JavaScript) code making AJAX calls to server side code in PHP that is mapped to classes of objects.
Usually the server side code needs to register classes or functions that will handle the AJAX calls.
However, when you have many classes to handle your Web application AJAX calls, registering classes one by one can be a tedious time consuming task.
The package provides a more efficient method to register many classes at once. You just specify a directory and the package will lookup and load the classes on demand when the AJAX calls are received.
This way you also do not have to waste time instantiating objects of the handler classes until they are necessary.
Manuel Lemos |
| |
|
|
Innovation award
Nominee: 1x |
|
Recommendations
Example
<?php
require (__DIR__ . '/vendor/autoload.php');
use Jaxon\Jaxon;
use Jaxon\Response\Response;
use Jaxon\Request\Factory as xr;
class HelloWorld
{
public function sayHello($isCaps)
{
if ($isCaps)
$text = 'HELLO WORLD!';
else
$text = 'Hello World!';
$xResponse = new Response();
$xResponse->assign('div2', 'innerHTML', $text);
return $xResponse;
}
public function setColor($sColor)
{
$xResponse = new Response();
$xResponse->assign('div2', 'style.color', $sColor);
return $xResponse;
}
}
// Register object
$jaxon = jaxon();
$jaxon->readConfigFile(__DIR__ . '/config/class.php', 'lib');
$jaxon->register(Jaxon::CALLABLE_OBJECT, new HelloWorld());
// Process the request, if any.
$jaxon->processRequest();
?>
<script type='text/javascript'>
/* <![CDATA[ */
window.onload = function() {
// Call the HelloWorld class to populate the 2nd div
<?php echo xr::call('HelloWorld.sayHello', 0) ?>;
// call the HelloWorld->setColor() method on load
<?php echo xr::call('HelloWorld.setColor', xr::select('colorselect')) ?>;
}
/* ]]> */
</script>
<div class="col-md-12" id="div2">
</div>
<div class="col-md-4 margin-vert-10">
<select class="form-control" id="colorselect" name="colorselect"
onchange="<?php echo xr::call('HelloWorld.setColor', xr::select('colorselect')) ?>; return false;">
<option value="black" selected="selected">Black</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
</select>
</div>
<div class="col-md-8 margin-vert-10">
<button type="button" class="btn btn-primary" onclick="<?php echo xr::call('HelloWorld.sayHello', 0) ?>; return false;" >Click Me</button>
<button type="button" class="btn btn-primary" onclick="<?php echo xr::call('HelloWorld.sayHello', 1) ?>; return false;" >CLICK ME</button>
</div>
|
Details
The Jaxon core library
Jaxon is an open source PHP library for easily creating Ajax web applications.
It allows into a web page to make direct Ajax calls to PHP classes that will in turn update its content, without reloading the entire page.
Jaxon is a fork of the Xajax PHP library.
This package is the Jaxon core library. Several plugins are provided in separate packages.
Features
-
All the Jaxon classes in a directory can be registered in one shot, possibly with a namespace.
-
The configuration settings can be loaded from a file. Supported formats are JSON, YAML and PHP.
-
The library provides pagination feature out of the box.
-
The library is modular, and consists of a core package and several plugin packages.
-
The javascript library is provided in a separated and javascript-only package, loaded by default from the jsDelivr CDN.
-
The generated javascript classes are named according to their namespace or the subdirectory where they are located.
-
All PHP packages install with `Composer`, are fully namespaced, and implement `PSR-4` autoloading.
-
The library natively implements Ajax file upload.
-
The library runs on PHP versions 5.4 to 7.X.
Documentation
The project documentation is available in English and French.
Some sample codes (only for version 2.x) are provided in the jaxon-php/jaxon-examples package, and demonstrated in the website.
Contribute
-
Issue Tracker: github.com/jaxon-php/jaxon-core/issues
-
Source Code: github.com/jaxon-php/jaxon-core
License
The project is licensed under the BSD license.
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.
|
Other classes that need this package |
|