PHP code example of bit-mx / saloon-logger-plug-in
1. Go to this page and download the library: Download bit-mx/saloon-logger-plug-in 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/ */
bit-mx / saloon-logger-plug-in example snippets
use BitMx\SaloonLoggerPlugIn\Traits\HasLogging;
use Saloon\Http\Connector;
class ExampleConnector extends Connector
{
use HasLogging;
public function resolveBaseUrl(): string
{
return 'https://example.com';
}
}
use BitMx\SaloonLoggerPlugIn\Traits\ProvidesDefaultBody;
use BitMx\SaloonLoggerPlugIn\Contracts\HasDefaultBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
class ExampleRequest extends Request implements HasDefaultBody
{
use ProvidesDefaultBody;
public function __construct(
public string $id,
) {}
protected Method $method = Method::GET;
public function resolveEndpoint(): string
{
return '/test';
}
protected function defaultBody(): array
{
return [
'id' => $this->id,
];
}
}
$connector = new ExampleConnector;
$request = new ExampleRequest($id);
$connector->send($request);
namespace App\Sanitizers;
use BitMx\SaloonLoggerPlugIn\Contracts\SanitizerRequestContract;
class MyRequestSanitizer implements SanitizerRequestContract
{
public static function sanitize(mixed $data): mixed
{
// perform your custom sanitization here
return $data;
}
}
namespace App\Sanitizers;
use BitMx\SaloonLoggerPlugIn\Contracts\SanitizerResponseContract;
use Saloon\Http\Response;
class MyResponseSanitizer implements SanitizerResponseContract
{
public static function sanitize(Response $data): mixed
{
// perform your custom sanitization here
return $data;
}
}