PHP code example of raorsa / sage-middleware-client
1. Go to this page and download the library: Download raorsa/sage-middleware-client 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/ */
raorsa / sage-middleware-client example snippets
use Raorsa\SageMiddlewareClient\Clients;
$clients = Clients::make(
url: 'https://middleware.ejemplo.com/api/',
user: '[email protected]',
password: 'secreto',
verify: true, // verificar certificado SSL
name: 'MiApp', // nombre del token generado en el login del middleware
cacheLife: 10, // minutos de vida del caché de respuestas (0 = sin caché)
cacheDir: null, // por defecto /tmp/sageCache.<hash del cwd>/
cacheCompress: true, // comprime el caché en disco (gzip)
logDir: null, // por defecto ./logs/
logLengthData: 100, // nº de caracteres de payload que se registran en el log
);
$listado = $clients->clients(); // GET /clients/list
$ficha = $clients->clientInfo('1234'); // GET /clients/info/1234
use Raorsa\SageMiddlewareClient\components\connexion;
use Raorsa\SageMiddlewareClient\wrappers\{cache, log};
use Raorsa\SageMiddlewareClient\Invoices;
$connexion = connexion::mount('https://middleware.ejemplo.com/api/', '[email protected]', 'secreto');
$invoices = Invoices::mount($connexion, new log(), new cache());
use Raorsa\SageMiddlewareClient\CustomClient;
$client = CustomClient::make(/* ... */);
$raw = $client->get('ruta/relativa', false); // string crudo de la respuesta
$json = $client->getJson('ruta/relativa', false); // decodificado como object|array|false
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.