PHP Classes

Jaxon: Call PHP classes from JavaScript using AJAX

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (130)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (1)    
Ratings Unique User Downloads Download Rankings
StarStarStarStarStar 80%Total: 585 This week: 1All time: 5,283 This week: 350Up
Version License PHP version Categories
jaxon-core 3.1.7BSD License5PHP 5, Language, AJAX, Traits
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
PHP Programming Innovation award nominee
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
Picture of Thierry Feuzeu
  Performance   Level  
Name: Thierry Feuzeu <contact>
Classes: 13 packages by
Country: Cameroon Cameroon
Innovation award
Innovation award
Nominee: 1x

Recommendations

Recommendation for a PHP class to how to call class and function
Call functions and class in PHP and HTML page

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">
                            &nbsp;
                        </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

Build Status Scrutinizer Code Quality StyleCI

Latest Stable Version Total Downloads Latest Unstable Version License

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.


  Hello World ClassExternal page   Hello World FunctionExternal page  

Open in a separate window

Open in a separate window

  Files folder image Files  
File Role Description
Files folder imagesrc (3 files, 8 directories)
Files folder imagetemplates (3 directories)
Files folder imagetests (2 directories)
Files folder imagetranslations (3 directories)
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file class.php Example Example of Jaxon class
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file hello.php Example Example of Jaxon function
Accessible without login Plain text file HOWTO.md Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Readme

  Files folder image Files  /  src  
File Role Description
Files folder imageApp (2 files)
Files folder imageContracts (2 files, 2 directories)
Files folder imageException (2 files)
Files folder imageFeatures (8 files, 3 directories)
Files folder imagePlugin (5 files, 1 directory)
Files folder imageRequest (1 file, 4 directories)
Files folder imageResponse (4 files, 2 directories)
Files folder imageUtils (12 directories)
  Accessible without login Plain text file CallableClass.php Class Class source
  Accessible without login Plain text file Jaxon.php Class Class source
  Accessible without login Plain text file start.php Example Example script

  Files folder image Files  /  src  /  App  
File Role Description
  Accessible without login Plain text file App.php Class Class source
  Accessible without login Plain text file Bootstrap.php Class Class source

  Files folder image Files  /  src  /  Contracts  
File Role Description
Files folder imageDialogs (2 files)
Files folder imageEvent (1 file)
  Accessible without login Plain text file Session.php Class Class source
  Accessible without login Plain text file View.php Class Class source

  Files folder image Files  /  src  /  Contracts  /  Dialogs  
File Role Description
  Accessible without login Plain text file Message.php Class Class source
  Accessible without login Plain text file Question.php Class Class source

  Files folder image Files  /  src  /  Contracts  /  Event  
File Role Description
  Accessible without login Plain text file Listener.php Class Class source

  Files folder image Files  /  src  /  Exception  
File Role Description
  Accessible without login Plain text file Error.php Class Class source
  Accessible without login Plain text file URI.php Class Class source

  Files folder image Files  /  src  /  Features  
File Role Description
Files folder imageDialogs (1 file)
Files folder imageRequest (1 file)
Files folder imageView (1 file)
  Accessible without login Plain text file App.php Class Class source
  Accessible without login Plain text file Config.php Class Class source
  Accessible without login Plain text file Event.php Class Class source
  Accessible without login Plain text file Manager.php Class Class source
  Accessible without login Plain text file Minifier.php Class Class source
  Accessible without login Plain text file Template.php Class Class source
  Accessible without login Plain text file Translator.php Class Class source
  Accessible without login Plain text file Validator.php Class Class source

  Files folder image Files  /  src  /  Features  /  Dialogs  
File Role Description
  Accessible without login Plain text file Message.php Class Class source

  Files folder image Files  /  src  /  Features  /  Request  
File Role Description
  Accessible without login Plain text file Factory.php Class Class source

  Files folder image Files  /  src  /  Features  /  View  
File Role Description
  Accessible without login Plain text file Namespaces.php Class Class source

  Files folder image Files  /  src  /  Plugin  
File Role Description
Files folder imageCode (1 file, 1 directory)
  Accessible without login Plain text file Manager.php Class Class source
  Accessible without login Plain text file Package.php Class Class source
  Accessible without login Plain text file Plugin.php Class Class source
  Accessible without login Plain text file Request.php Class Class source
  Accessible without login Plain text file Response.php Class Class source

  Files folder image Files  /  src  /  Plugin  /  Code  
File Role Description
Files folder imageContracts (1 file)
  Accessible without login Plain text file Generator.php Class Class source

  Files folder image Files  /  src  /  Plugin  /  Code  /  Contracts  
File Role Description
  Accessible without login Plain text file Generator.php Class Class source

  Files folder image Files  /  src  /  Request  
File Role Description
Files folder imageFactory (5 files, 2 directories)
Files folder imageHandler (3 files)
Files folder imagePlugin (4 files)
Files folder imageSupport (6 files)
  Accessible without login Plain text file Target.php Class Class source

  Files folder image Files  /  src  /  Request  /  Factory  
File Role Description
Files folder imageCallableClass (2 files)
Files folder imageContracts (1 file)
  Accessible without login Plain text file JsCall.php Class Class source
  Accessible without login Plain text file Parameter.php Class Class source
  Accessible without login Plain text file ParameterFactory.php Class Class source
  Accessible without login Plain text file Request.php Class Class source
  Accessible without login Plain text file RequestFactory.php Class Class source

  Files folder image Files  /  src  /  Request  /  Factory  /  CallableClass  
File Role Description
  Accessible without login Plain text file Paginator.php Class Class source
  Accessible without login Plain text file Request.php Class Class source

  Files folder image Files  /  src  /  Request  /  Factory  /  Contracts  
File Role Description
  Accessible without login Plain text file Parameter.php Class Class source

  Files folder image Files  /  src  /  Request  /  Handler  
File Role Description
  Accessible without login Plain text file Argument.php Class Class source
  Accessible without login Plain text file Callback.php Class Class source
  Accessible without login Plain text file Handler.php Class Class source

  Files folder image Files  /  src  /  Request  /  Plugin  
File Role Description
  Accessible without login Plain text file CallableClass.php Class Class source
  Accessible without login Plain text file CallableDir.php Class Class source
  Accessible without login Plain text file CallableFunction.php Class Class source
  Accessible without login Plain text file FileUpload.php Class Class source

  Files folder image Files  /  src  /  Request  /  Support  
File Role Description
  Accessible without login Plain text file CallableFunction.php Class Class source
  Accessible without login Plain text file CallableObject.php Class Class source
  Accessible without login Plain text file CallableRegistry.php Class Class source
  Accessible without login Plain text file CallableRepository.php Class Class source
  Accessible without login Plain text file FileUpload.php Class Class source
  Accessible without login Plain text file UploadedFile.php Class Class source

  Files folder image Files  /  src  /  Response  
File Role Description
Files folder imageFeatures (3 files)
Files folder imagePlugin (1 file, 1 directory)
  Accessible without login Plain text file AbstractResponse.php Class Class source
  Accessible without login Plain text file Manager.php Class Class source
  Accessible without login Plain text file Response.php Class Class source
  Accessible without login Plain text file UploadResponse.php Class Class source

  Files folder image Files  /  src  /  Response  /  Features  
File Role Description
  Accessible without login Plain text file DomCommands.php Class Class source
  Accessible without login Plain text file DomTreeCommands.php Class Class source
  Accessible without login Plain text file JsCommands.php Class Class source

  Files folder image Files  /  src  /  Response  /  Plugin  
File Role Description
Files folder imageJQuery (2 directories)
  Accessible without login Plain text file JQuery.php Class Class source

  Files folder image Files  /  src  /  Response  /  Plugin  /  JQuery  
File Role Description
Files folder imageCall (3 files)
Files folder imageDom (1 file)

  Files folder image Files  /  src  /  Response  /  Plugin  /  JQuery  /  Call  
File Role Description
  Accessible without login Plain text file AttrGet.php Class Class source
  Accessible without login Plain text file AttrSet.php Class Class source
  Accessible without login Plain text file Method.php Class Class source

  Files folder image Files  /  src  /  Response  /  Plugin  /  JQuery  /  Dom  
File Role Description
  Accessible without login Plain text file Element.php Class Class source

  Files folder image Files  /  src  /  Utils  
File Role Description
Files folder imageConfig (5 files, 1 directory)
Files folder imageDI (1 file)
Files folder imageDialogs (3 files)
Files folder imageHttp (1 file)
Files folder imageInterfaces (1 file)
Files folder imagePagination (2 files)
Files folder imageSession (1 file)
Files folder imageTemplate (4 files)
Files folder imageTraits (1 file)
Files folder imageTranslation (1 file)
Files folder imageValidation (1 file)
Files folder imageView (3 files)

  Files folder image Files  /  src  /  Utils  /  Config  
File Role Description
Files folder imageException (3 files)
  Accessible without login Plain text file Config.php Class Class source
  Accessible without login Plain text file Json.php Class Class source
  Accessible without login Plain text file Php.php Class Class source
  Accessible without login Plain text file Reader.php Class Class source
  Accessible without login Plain text file Yaml.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Config  /  Exception  
File Role Description
  Accessible without login Plain text file Data.php Class Class source
  Accessible without login Plain text file File.php Class Class source
  Accessible without login Plain text file Yaml.php Class Class source

  Files folder image Files  /  src  /  Utils  /  DI  
File Role Description
  Accessible without login Plain text file Container.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Dialogs  
File Role Description
  Accessible without login Plain text file Dialog.php Class Class source
  Accessible without login Plain text file Message.php Class Class source
  Accessible without login Plain text file Question.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Http  
File Role Description
  Accessible without login Plain text file URI.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Interfaces  
File Role Description
  Accessible without login Plain text file EventListener.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Pagination  
File Role Description
  Accessible without login Plain text file Paginator.php Class Class source
  Accessible without login Plain text file Renderer.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Session  
File Role Description
  Accessible without login Plain text file Manager.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Template  
File Role Description
  Accessible without login Plain text file Context.php Class Class source
  Accessible without login Plain text file Engine.php Class Class source
  Accessible without login Plain text file Minifier.php Class Class source
  Accessible without login Plain text file View.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Traits  
File Role Description
  Accessible without login Plain text file Event.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Translation  
File Role Description
  Accessible without login Plain text file Translator.php Class Class source

  Files folder image Files  /  src  /  Utils  /  Validation  
File Role Description
  Accessible without login Plain text file Validator.php Class Class source

  Files folder image Files  /  src  /  Utils  /  View  
File Role Description
  Accessible without login Plain text file Manager.php Class Class source
  Accessible without login Plain text file Renderer.php Class Class source
  Accessible without login Plain text file Store.php Class Class source

  Files folder image Files  /  templates  
File Role Description
Files folder imagepagination (1 file, 1 directory)
Files folder imageplugins (6 files)
Files folder imagesupport (3 files)

  Files folder image Files  /  templates  /  pagination  
File Role Description
Files folder imagelinks (5 files)
  Accessible without login Plain text file wrapper.php Example Example script

  Files folder image Files  /  templates  /  plugins  
File Role Description
  Accessible without login Plain text file config.js.php Example Example script
  Accessible without login Plain text file confirm.js.tpl Data Auxiliary data
  Accessible without login Plain text file errors.txt.php Example Example script
  Accessible without login Plain text file include.js.php Example Example script
  Accessible without login Plain text file includes.js.php Example Example script
  Accessible without login Plain text file wrapper.js.php Example Example script

  Files folder image Files  /  templates  /  support  
File Role Description
  Accessible without login Plain text file event.js.php Example Example script
  Accessible without login Plain text file function.js.php Example Example script
  Accessible without login Plain text file object.js.php Example Example script

  Files folder image Files  /  tests  
File Role Description
Files folder imageRegistration (1 file, 1 directory)
Files folder imageRequest (1 file, 1 directory)

  Files folder image Files  /  tests  /  Registration  
File Role Description
Files folder imagedefs (1 directory)
  Accessible without login Plain text file FunctionTest.php Class Class source

  Files folder image Files  /  tests  /  Registration  /  defs  
File Role Description
Files folder imagecallables (2 files)

  Files folder image Files  /  tests  /  Registration  /  defs  /  callables  
File Role Description
  Accessible without login Plain text file classes.php Class Class source
  Accessible without login Plain text file functions.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  Request  
File Role Description
Files folder imageCallableClass (1 file, 1 directory)
  Accessible without login Plain text file RequestTest.php Class Class source

  Files folder image Files  /  tests  /  Request  /  CallableClass  
File Role Description
Files folder imagedefs (1 file)
  Accessible without login Plain text file RequestTest.php Class Class source

  Files folder image Files  /  tests  /  Request  /  CallableClass  /  defs  
File Role Description
  Accessible without login Plain text file classes.php Class Class source

  Files folder image Files  /  translations  
File Role Description
Files folder imageen (3 files)
Files folder imagees (3 files)
Files folder imagefr (3 files)

  Files folder image Files  /  translations  /  en  
File Role Description
  Accessible without login Plain text file config.php Aux. Auxiliary script
  Accessible without login Plain text file errors.php Aux. Auxiliary script
  Accessible without login Plain text file upload.php Aux. Auxiliary script

  Files folder image Files  /  translations  /  es  
File Role Description
  Accessible without login Plain text file config.php Aux. Auxiliary script
  Accessible without login Plain text file errors.php Aux. Auxiliary script
  Accessible without login Plain text file upload.php Aux. Auxiliary script

  Files folder image Files  /  translations  /  fr  
File Role Description
  Accessible without login Plain text file config.php Aux. Auxiliary script
  Accessible without login Plain text file errors.php Aux. Auxiliary script
  Accessible without login Plain text file upload.php Aux. Auxiliary script

 Version Control Reuses Unique User Downloads Download Rankings  
 96%3
Total:585
This week:1
All time:5,283
This week:350Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:100%StarStarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:80%StarStarStarStarStar
Rank:17