Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
70% | Total: 670 | All time: 4,827 This week: 50 |
Version | License | PHP version | Categories | |||
server 1.0.0 | BSD License | 5 | PHP 5, Web services |
Description | Author | |||
This package can handle REST API requests with functions in scripts. Innovation Award
|
JSONful is a framework which helps creating API servers.
composer require jsonful/server
api.php
require __DIR__ . '/vendor/autoload.php';
$server new JSONful\Server(__DIR__ . '/apps');
$server->run();
apps/prime.php
/ @API("prime") */
function is_prime($number)
{
if ($number <= 0) {
return false;
}
$middle = ceil($number/2);
for ($i = 2; $i <= $middle; ++$i) {
if ($number % $i === 0) {
return false;
}
}
return true;
}
/ @API("ping") */
function ping() {
return ['pong' => time()];
}
client.js
var client = new JSONful("https://api.myapp.net/");
client.exec("ping", function(err, response) {
console.log(response); // {"pong": xxxx}
}
client.exec("prime", 99).then(function(response) {
console.error(response); // false
});
Files (32) |
File | Role | Description | ||
---|---|---|---|---|
src (1 directory) | ||||
tests (3 files, 2 directories) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (32) | / | src | / | JSONful |
File | Role | Description | ||
---|---|---|---|---|
Client (2 files) | ||||
Session (2 files) | ||||
Response.php | Class | Class source | ||
RetryException.php | Class | Class source | ||
Server.php | Class | Class source |
Files (32) | / | src | / | JSONful | / | Client |
File | Role | Description |
---|---|---|
Request.php | Class | Class source |
Requests.php | Class | Class source |
Files (32) | / | src | / | JSONful | / | Session |
File | Role | Description |
---|---|---|
Native.php | Class | Class source |
Storage.php | Class | Class source |
Files (32) | / | tests |
File | Role | Description | ||
---|---|---|---|---|
apps (6 files) | ||||
features (11 files) | ||||
bootstrap.php | Aux. | Auxiliary script | ||
SessionStorage.php | Test | Class source | ||
SimpleTest.php | Test | Class source |
Files (32) | / | tests | / | apps |
File | Role | Description |
---|---|---|
error.php | Aux. | Auxiliary script |
filter.php | Aux. | Auxiliary script |
prime.php | Aux. | Auxiliary script |
session.php | Aux. | Auxiliary script |
simple.php | Aux. | Example script |
two.php | Aux. | Auxiliary script |
Files (32) | / | tests | / | features |
File | Role | Description |
---|---|---|
empty.json | Data | Auxiliary data |
error.json | Data | Auxiliary data |
internal-error.json | Data | Auxiliary data |
multiple.json | Data | Auxiliary data |
not-found.json | Data | Auxiliary data |
preload-context.json | Data | Auxiliary data |
preload-with-name.json | Data | Auxiliary data |
preload.json | Data | Auxiliary data |
preroute.json | Data | Auxiliary data |
retry.json | Data | Auxiliary data |
simple.json | Data | Auxiliary data |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | ||||||||||||||||||||||||||||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.