https://github.com/journy-io/php-sdk
π The official PHP SDK that you can use to easily interact with our API
https://github.com/journy-io/php-sdk
php php7 php8 sdk sdk-php
Last synced: 7 months ago
JSON representation
π The official PHP SDK that you can use to easily interact with our API
- Host: GitHub
- URL: https://github.com/journy-io/php-sdk
- Owner: journy-io
- License: mit
- Created: 2020-07-09T07:36:59.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-13T18:07:27.000Z (about 2 years ago)
- Last Synced: 2025-03-24T15:41:31.362Z (8 months ago)
- Topics: php, php7, php8, sdk, sdk-php
- Language: PHP
- Homepage: https://developers.journy.io
- Size: 548 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://journy.io/?utm_source=github&utm_content=readme-php-sdk)
# journy.io PHP SDK
[](https://packagist.org/packages/journy-io/sdk)
[](https://packagist.org/packages/journy-io/sdk)
[](https://packagist.org/packages/journy-io/sdk)
[](LICENSE)
This is the official PHP SDK for [journy.io](https://journy.io?utm_source=github&utm_content=readme-php-sdk).
## πΎ Installation
You can use composer to install the SDK:
```bash
composer require journy-io/sdk
```
You will also need a PSR-7 implementation (HTTP messages), PSR-17 implementation (HTTP factory) and PSR-18 implementation (HTTP client).
If your app doesn't have these yet installed, we recommend:
```bash
composer require kriswallsmith/buzz nyholm/psr7
```
- [https://github.com/kriswallsmith/Buzz](https://github.com/kriswallsmith/Buzz)
- [https://github.com/Nyholm/psr7](https://github.com/Nyholm/psr7)
## π Getting started
### Configuration
To be able to use the SDK you need to generate an API key. If you don't have one you can create one in [journy.io](https://system.journy.io?utm_source=github&utm_content=readme-php-sdk).
If you don't have an account yet, you can create one in [journy.io](https://system.journy.io/register?utm_source=github&utm_content=readme-php-sdk) or [request a demo first](https://www.journy.io/book-demo?utm_source=github&utm_content=readme-php-sdk).
Go to your settings, under the _Connections_-tab, to create and edit API keys. Make sure to give the correct permissions to the API Key.
```php
use JournyIO\SDK\Client;
// composer require kriswallsmith/buzz nyholm/psr7
$client = Client::withDefaults("your-api-key");
```
If you want to use your own HTTP client (PSR-18):
```php
use Buzz\Client\Curl;
use JournyIO\SDK\Client;
use Nyholm\Psr7\Factory\Psr17Factory;
// https://github.com/Nyholm/psr7
$factory = new Psr17Factory();
// https://github.com/kriswallsmith/Buzz
$http = new Curl($factory, ["timeout" => 5]);
$client = new Client($http, $factory, $factory, ["apiKey" => "your-api-key"]);
```
### Methods
#### Get API key details
```php
use JournyIO\SDK\ApiKeyDetails;
$call = $client->getApiKeyDetails();
if ($call->succeeded()) {
$result = $call->result();
if ($result instanceof ApiKeyDetails) {
var_dump($result->getPermissions()); // string[]
}
} else {
var_dump($call->errors());
}
```
### Handling errors
Every call will return a result, we don't throw errors when a call fails. We don't want to break your application when things go wrong. An exception will be thrown for required arguments that are empty or missing.
```php
$call = $client->getTrackingSnippet("blog.acme.com");
var_dump($call->succeeded()); // bool
var_dump($call->rateLimited()); // bool
var_dump($call->remainingRequests()); // int
var_dump($call->maxRequests()); // int
var_dump($call->errors()); // array
```
## π¬ API Docs
[API reference](https://developers.journy.io)
## π― Tests
To run the tests:
```bash
composer run test
```
## β Help
We welcome your feedback, ideas and suggestions. We really want to make your life easier, so if weβre falling short or should be doing something different, we want to hear about it.
Please create an issue or contact us via the chat on our website.
## π Security
If you discover any security related issues, please email security at journy io instead of using the issue tracker.