PHP Classes


Recommend this page to a friend!
  Classes of John Diaz   PHP Silex REST Multi Lazy Load   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Silex REST Multi Lazy Load
Create REST APIs with module lazy loading
Author: By
Last change: Update
Date: 6 years ago
Size: 2,203 bytes


Class file image Download


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

For multiple API interfaces, just create a new dir:


.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:


Point to:


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": "", "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.