PHP Silex REST Multi Lazy Load: Create REST APIs with module lazy loading

Recommend this page to a friend!
  Info   View files Documentation   View files View files (27)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 174 All time: 8,582 This week: 224Up
Version License PHP version Categories
silex-rest-api-multi 1.0GNU General Publi...5PHP 5, Libraries, Web services
Collaborate with this project Author
Description

This package can be used to create REST APIs with module lazy loading.

It takes a configuration file that is loaded from the config directory and handles REST API requests using micro-service classes.

The package can route the requests and lazy-load service classes, i.e. on demand when the API requests are performed. It supports authentication of API users.

Innovation Award
PHP Programming Innovation award nominee
July 2016
Number 5


Prize: One ebook of choice by Packt
Many packages can implement APIs that map requests to classes that will handle the API requests.

Great part of those packages require that you create objects that will handle the API requests.

This package simplifies the process by just specifying the name of the modules that will handle the requests.

This way the package will only load the classes and create the necessary micro-service and controller objects when the respective API requests are received.

Manuel Lemos
Picture of John Diaz
  Performance   Level  
Name: John Diaz <contact>
Classes: 3 packages by
Country: Colombia Colombia
Age: 38
All time rank: 286117 in Colombia Colombia
Week rank: 616 Up5 in Colombia Colombia Up
Innovation award
Innovation award
Nominee: 1x

Details

silex-rest-api-multi-lazyload

This is a SILEX based Rest API with module lazy load, it uses micro services and has authentication. It uses token authentication and is useful for Angularjs Applications, it also uses Yandex service to translate strings for internationalization.

This api can be used for exposing different web services, that means that every service can have its own workspace and database configuration, it is built in a modular fashion, where removing any part won't affect the whole functionality.

Api Refecence

https://secureaudit.co/api-docs

For multiple API interfaces, just create a new dir:

public2/
.htaccess
index.php

.htaccess file contents:

 #Options -MultiViews
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [L]

index.php contents:

 require_once __DIR__ . '/../vendor/autoload.php';
 $app = App\Rest::run('prod2');

Create a prod2.php config file under ./config/

_About the Lazy Load._

This rest API uses lazy loading for services, it has a Factory pattern implemented so all naming conventions must be kept for controllers and services.

Do the following to run:

composer install 
php -S 0:8001 -t public1/

Run tests:

 vendor/bin/phpunit 

Point to:

 http://localhost:8001/api/v1/whatever

HTTP Request Headers:

 'Content-Type: application/json'
 'x-token: your-auth-token'

License see LICENSE file.

Authentication method:

curl -i -H "x-requested-with: CLFYf7yz1it9x16FX1b5rlDNp3qkXJWB" -H "Content-Type: application/json" -X-POST http://localhost:8001/api/v1/login -d '{
  "login": { "email": "test@example.com", "pass": $apiPass //"04fbd445b467cf8679232accbcedf6192070d068"}
}'

How to generate passwords

$appKey  = 'CLFYf7yz1it9x16FX1b5rlDNp3qkXJWB';
$pass    = sha1('User123!*?'); //43e1eeda52d762652c2846badea1dd6a2a761d81
$apiPass = sha1($appKey.$pass); //04fbd445b467cf8679232accbcedf6192070d068

Login Headers, company token:

'x-requested-with: CLFYf7yz1it9x16FX1b5rlDNp3qkXJWB'
'Content-Type: application/json'

I owe you unit tests, sorry, test writers are welcome!!, any questions just contact me.

  Files folder image Files  
File Role Description
Files folder imageconfig (1 file)
Files folder imagedb (1 file)
Files folder imagepublic1 (2 files)
Files folder imagesrc (1 directory)
Accessible without login Plain text file .gitignore Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
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. Documentation

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file prod1.php Aux. Auxiliary script

  Files folder image Files  /  db  
File Role Description
  Accessible without login Plain text file db.sql Data Auxiliary data

  Files folder image Files  /  public1  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imageApp (8 files, 1 directory)

  Files folder image Files  /  src  /  App  
File Role Description
Files folder imageServices (1 directory)
  Plain text file Authorization.php Class Class source
  Plain text file BaseRestApi.php Class Class source
  Plain text file BaseService.php Class Class source
  Plain text file Controller.php Class Class source
  Plain text file Purifier.php Class Class source
  Plain text file Rest.php Class Class source
  Plain text file Route.php Class Class source
  Plain text file Routing.php Class Class source

  Files folder image Files  /  src  /  App  /  Services  
File Role Description
Files folder imageRest (5 directories)

  Files folder image Files  /  src  /  App  /  Services  /  Rest  
File Role Description
Files folder imageCountries (2 files)
Files folder imageCustomers (2 files)
Files folder imageLanguage (2 files)
Files folder imageLogin (2 files)
Files folder imageUsers (2 files)

  Files folder image Files  /  src  /  App  /  Services  /  Rest  /  Countries  
File Role Description
  Plain text file CountriesController.php Class Class source
  Plain text file CountriesService.php Class Class source

  Files folder image Files  /  src  /  App  /  Services  /  Rest  /  Customers  
File Role Description
  Plain text file CustomersController.php Class Class source
  Plain text file CustomersService.php Class Class source

  Files folder image Files  /  src  /  App  /  Services  /  Rest  /  Language  
File Role Description
  Plain text file LanguageController.php Class Class source
  Plain text file LanguageService.php Class Class source

  Files folder image Files  /  src  /  App  /  Services  /  Rest  /  Login  
File Role Description
  Plain text file LoginController.php Class Class source
  Plain text file LoginService.php Class Class source

  Files folder image Files  /  src  /  App  /  Services  /  Rest  /  Users  
File Role Description
  Plain text file UsersController.php Class Class source
  Plain text file UsersService.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:174
This week:0
All time:8,582
This week:224Up

For more information send a message to info at phpclasses dot org.