happydemon/saloon-utils

Utilities for building Saloon SDKs

0.1.0 2025-07-10 11:41 UTC

This package is auto-updated.

Last update: 2025-07-13 16:00:10 UTC


README

Latest Version on Packagist Tests Status Tests Coverage

Batteries for Saloon.

Installation

Via Composer

composer require happydemon/saloon-utils
php artisan vendor:publish --tag saloon-utils.config

Request logging

Ensure your connector uses the HappyDemon\SaloonUtils\Logger\LoggerPlugin trait.

If request logging is enabled, by default, requests will be logged with the HappyDemon\SaloonUtils\Logger\SaloonRequest model.

# Disable saloon request logging globally, if not defined, defaults to true
SALOON_REQUEST_LOGS=false

When using the default built-in database logger, you'll have to publish & run migrations;

php artisan vendor:publish --tag saloon-utils.migrations
php artisan migrate

Request logging

By default, the database logger is used, however, a bundled logger is also available that stores requests in memory, which can be helpful for local debugging and testing. You can always register your own.

Each logger implements HappyDemon\SaloonUtils\Logger\Contracts\Logger:

  • HappyDemon\SaloonUtils\Logger\Stores\DatabaseLogger
  • HappyDemon\SaloonUtils\Logger\Stores\MemoryLogger

You can set the default logger by binding the Logger contract in the service container.

You are also able to define a specific logger on a Connector class.

Generally, all requests sent by your Connector will be logged.

Ignoring requests

You can ensure individual requests are ignored by implementing HappyDemon\SaloonUtils\Logger\Contracts\DoNotLogRequest on the Request class.

If you want more fine-grained control over which requests should be logged, you can implement HappyDemon\SaloonUtils\Logger\Contracts\ConditionallyIgnoreLogs on your Connector or Request class. This contract allows you to implement your checks through public function shouldLogRequest(PendingRequest $pendingRequest): bool;.

Pruning

@todo command that prunes old request logs

Changelog

Please refer to the changelog for more information on recent changes.

Testing

$ composer test

Contributing

Please see contributing.md for details and a to-do list.

Security

If you discover any security-related issues, please email maxim.kerstens@gmail.com instead of using the issue tracker.

Credits

License

MIT