1. Go to this page and download the library: Download ruima/microservice-tool library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ruima / microservice-tool example snippets
$app->singleton(
'MicroserviceTool', function ($app) {
return new Ruima\MicroserviceTool\Slaver($app);
}
);
$app->routeMiddleware([
'auth' => Ruima\MicroserviceTool\Middleware\FackAuth::class,
'permission' => Ruima\MicroserviceTool\Middleware\Permission::class,
]);
$app->register(Ruima\MicroserviceTool\Provider\SlaverProvider::class);
#use app('MicroserviceTool') to get the MicroserviceTool Object
app('MicroserviceTool')->{methods};
# return an Array for microservice infos
getSlaverInfo()
# send the request to tell gateway destory the user cache in gateway
destoryAuth()
# return a String for target microservice url
getServerUrl(String $service_name)
# return a http body which the target microserver callback
get(String $service_name, String $url = '/the/route/which/defind/in/web.php/or/api.php', Array $guzzle_config = [])
post(String $service_name, String $url, Array $guzzle_config)
delete(String $service_name, String $url, Array $guzzle_config)
put(String $service_name, String $url, Array $guzzle_config)