joppedc / logsnag-php-sdk
An integration of the Logsnag API for PHP
Installs: 5 239
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- php-http/discovery: ^1.15
- psr/http-client-implementation: *
- psr/http-factory-implementation: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
- guzzlehttp/guzzle: ^7.5
- php-vcr/php-vcr: 1.5.5
- php-vcr/phpunit-testlistener-vcr: ^3.1
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-01-15 14:33:06 UTC
README
Realtime monitoring, for your entire business. A LogSnag PHP SDK.
Unofficial PHP SDK
Getting started
Install
To install the SDK you will need to be using Composer in your project. To install it please see the composer docs.
This is the "core" SDK, meaning that all the core logic and models are here.
If you are happy with using your own HTTP client, install the SDK
like: joppedc/logsnag-php-sdk
composer require joppedc/logsnag-php-sdk
This package (joppedc/logsnag-php-sdk
) is not tied to any specific library that sends HTTP messages. Instead,
it uses Httplug to let users choose whichever
PSR-7 implementation and HTTP client they want to use.
If you just want to get started quickly you should run the following command:
composer require joppedc/logsnag-php-sdk php-http/curl-client
This will install the library itself along with an HTTP client adapter that uses cURL as transport method (provided by Httplug). You do not have to use those packages if you do not want to. The SDK does not care about which transport method you want to use because it's an implementation detail of your application.
Configuration
new JoppeDc\LogsnagPhpSdk\Client("your_secret_key");
Usage
Create new log event
$payload = new JoppeDc\LogsnagPhpSdk\Contracts\LogPayload( 'project_name', 'channel_name', 'event_name' ); $payload->setDescription('test-description'); $payload->setTags(['tag' => 'tag value']); $payload->setIcon('😀'); $log = $this->client->createLog($payload);
Create new insight event
$payload = new JoppeDc\LogsnagPhpSdk\Contracts\InsightPayload( 'project_name', 'title', 5 ); $payload->setIcon('😀'); $insight = $this->client->createInsight($payload);
Mutate an insight event
$payload = new JoppeDc\LogsnagPhpSdk\Contracts\MutateInsightPayload( 'project_name', 'title', -5 ); $payload->setIcon('😀'); $insight = $this->client->mutateInsight($payload);