PHP Classes

Easy API: Handle API calls by mapping requests to functions

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 185 All time: 8,656 This week: 455Up
Version License PHP version Categories
easyapi 1.0.0GNU General Publi...5PHP 5, Web services
Description 

Author

This package can be used to handle API calls by mapping requests to given functions.

It can take arrays with the names of functions that will be called when API requests are sent to URLs with the same names of the functions.

Those functions that care of outputting the response to the API requests eventually encoding the responses in JSON format.

Picture of Luis Toscano
  Performance   Level  
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

 

Example

<?php

/*
  ___ ______ _____ _ _ ___ ___
 / _ \| ___ \_ _| | | | | | \/ |
/ /_\ \ |_/ / | | | | ___ ___ | | _| . . | ___
| _ | __/ | | | | / _ \ / _ \| |/ / |\/| |/ _ \
| | | | | _| |_ | |___| (_) | (_) | <| | | | __/
\_| |_|_| \___/ \_____/\___/ \___/|_|\_\_| |_/\___|
                                                       
                                                  

*/

 ////// Definitions
 
 //include 'config/config.php';

 
define('LIBS', 'libs');
 
$qs = $_SERVER['QUERY_STRING'];
 
$config = ['appserver' => 'ionic', 'jwtenabled' => true];
 
$factory = array();
 
$library = array(
 
'mixing' => '',
 
'orm' => $link
 
);

////// SimpleCore
 
include 'config/_bootstrap.php';
 include
'config/easyAuth.php';

////// Security Actions
 
$onlypost = array('save','get');

////// Actions Zone

function hello(){
  GLOBAL
$factory;
  echo
'?? lol ??';
}

function
halo(){
  echo
'?? aloh ??';
}

function
trucks($json = false){
  if(
$json == 'json'){
    echo
json_encode(factory(null, 'orm')->query("SELECT * FROM trucks"));
  }else{
    echo
factory(null, 'orm')->toTable("SELECT * FROM trucks");
  }
}

function
save($data = array()){
  GLOBAL
$factory;
  echo
'Saving Data '.$data['ipclient'];
 
factory(null, 'orm')->insert(array('tabla' => 'look_track', 'reg' => array('ip'=>$data['ipclient'], 'hostname'=>$data['hostname'])));
}


////// Simple Execute API

runner();




Details

EasyApi

The Custom Pack for Develoment Apis by PHP Mixed ( Functional &amp; OOP )

Easy & Custom pack for develoment api and microservices based in PHP, use a mixed programing techniques - Functional and OOP

For Testing.

- Edit Config file for database conections. - Place any libraries to use in libs forlder - Add a classname in the array at the api.php file - Runn Runn and Test. - Edit EasyAuth.php in the config folder, change $secret, this variable is the seed of security encrypt

My Powers

- Friendly with Ionic Apps. - Fast. - Add Your Power. - JWT Support - New

Notices for JWT

Request to jwtgenerate for generate the token, this token have a TTL by default in one hour.

EasyApi Use

- PHP - MySQL - OOP - Functional Programing - Factory Pattern - Object Injected - Routing Dinamic - JWT for PHP

Beauty V0 Beta. jejeje


  Files folder image Files (27)  
File Role Description
Files folder imageconfig (3 files, 1 directory)
Files folder imagehtml (1 file)
Files folder imagelibs (3 files)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file api.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

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 Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:185
This week:0
All time:8,656
This week:455Up