PHP Classes
elePHPant
Icontem

Div PHP Ajax Mapping: Call PHP classes and functions using AJAX requests

Recommend this page to a friend!
  Info   View files Example   View files View files (16)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-10-12 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 517 All time: 5,534 This week: 556Up
Version License PHP version Categories
div-ajax-mapping 1.3GNU General Publi...5.4PHP 5, Web services, AJAX
Collaborate with this project Author
Description

This package can be used to call PHP classes and functions using AJAX requests.

It can register classes or global functions that will handle the responses to specified AJAX requests.

The server class then can handle the requests and invoke the registered methods.

It can also register requests for specific data values that may be returned as responses to AJAX requests without having to register a specific function for returning that data.

Innovation Award
PHP Programming Innovation award nominee
January 2015
Number 6
Many applications need to implement APIs that will be used to respond to AJAX requests performing some action.

A very common solution to implement this kind of API is to register some functions or classes that will generate the responses to the API calls.

However, in some cases the response for some types of requests is to return data already stored in variables or some other type of registered.

This class provides a simpler solution to return registered data without having to register a specific function.

Manuel Lemos
  Performance   Level  
Name: Rafael Rodriguez <contact>
Classes: 4 packages by
Country: Cuba Cuba
Age: 31
All time rank: 19104 in Cuba Cuba
Week rank: 95 Up1 in Cuba Cuba Up
Innovation award
Innovation award
Nominee: 2x

Details
PHP Hot Mapping

Hot Mapping of PHP data, functions and methods in JavaScript

phpHotMap is an open source library for JavaScript and PHP, that 
allow mapping the PHP functions, static methods of classes and 
arbitrary data on the spot of the instance a JavaScript class. 
With this class you can call a functions and methods via AJAX. 

For example:

--------------------------------------------
In the server:
--------------------------------------------
<?php

// Include the library 

include "phpHotMap.php";
include "phpHotMapServer.php";  

// The program 
// Note: the programa can be located in an external file 

function sum($x, $y){
  return $x + $y; 
}

class Enterprise{
  public function getEmployees(){
      return array(
        array("name" => "Thomas Hardy", "salary" => 1500),  
        array("name" => "Christina Berglund", "salary" => 1200)  
      );  
    } 
} 

// Server instance ...

$server = new phpHotMaServer(); 

// ... Add methods ...

$server->addMethod("sum", "x,y"); 
$server->addMethod("Enterprise::getEmployees", "x,y"); 

// ... and go!
$server->go(); 

?>
--------------------------------------------
In the client:
--------------------------------------------
<script type = "text/javascript" src="phpHotMap.js"></script>
<script type = "text/javascript">

    var client = new phpHotMapClient("server.php");
    
    var sum = client.sum(20, 10);
    
    var employees = client.Enterprise.getEmployees();
    
    var firstEmployeeName = employees[0]['name'];

</script>
  Files folder image Files  
File Role Description
Files folder imageexample (2 files)
Accessible without login Plain text file .gitignore Data new
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file divAjaxMapping.js Data Auxiliary data
Plain text file divAjaxMapping.php Class Class source
Accessible without login Plain text file exampleClient.js Data Auxiliary data
Accessible without login HTML file examplePage.html Doc. Documentation
Plain text file exampleServer.php Class Class source
Accessible without login Plain text file LICENSE Data Auxiliary data
Accessible without login Plain text file LICENSE.txt Lic. first commit
Accessible without login Plain text file phpHotMap.js Data first commit
Plain text file phpHotMap.php Class first commit
Plain text file phpHotMapServer.php Class first commit
Plain text file README.md Class Class source
Accessible without login Plain text file README.txt Doc. first commit

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file client.js Example first commit
  Accessible without login Plain text file server.php Example first commit

 Version Control Unique User Downloads Download Rankings  
 68%
Total:517
This week:0
All time:5,534
This week:556Up