happydemon / saloon-utils
Utilities for building Saloon SDKs
Requires
- php: ~8.2|~8.3|~8.4
- illuminate/support: ~11.0|~12.0
- saloonphp/saloon: ^3.0
Requires (Dev)
- orchestra/testbench: ~9|~10
- phpunit/phpunit: ~10.0|~11.0|~12.0
- roave/security-advisories: dev-latest
README
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