billbeeio / billbee-php-sdk

🔌 The official Billbee API SDK for PHP 💻
MIT License
23 stars 25 forks source link

Prerelase 2.1: Declaration of Psr\Log\NullLogger: must be compatible with ... #67

Closed Goldfischpeter closed 2 years ago

Goldfischpeter commented 2 years ago

Prerelase 2.1 Initialising with api credentials

Declaration of Psr\Log\NullLogger::log($level, Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerInterface::log($level, $message, array $context = [])

devtronic commented 2 years ago

Can you please provide a minimal example including your composer.json?

Psr\Log\NullLogger comes from https://github.com/php-fig/log/blob/master/src/NullLogger.php which is outside of the billbee-php-sdk scope.

You could also try to update the psr/log package in your project.

Goldfischpeter commented 2 years ago

{ "name": "billbee/billbee-api", "description": "The official Billbee API SDK for PHP", "type": "library", "require": { "php-64bit": "^7.3 || ^8.0", "ext-curl": "", "ext-json": "", "guzzlehttp/guzzle": "^7.4.0", "psr/log": "^1.1.0 || ^2.0.0 || ^3.0.0", "jms/serializer": "^3.18" }, "require-dev": { "phpunit/phpunit": "^9.4.1", "friendsofphp/php-cs-fixer": "^2.15", "phpstan/phpstan": "^1.8.2" }, "license": "MIT", "authors": [ { "name": "Julian Finkler", "email": "julian@billbee.io" } ], "minimum-stability": "stable", "autoload": { "psr-4": { "BillbeeDe\BillbeeAPI\": "src/", "BillbeeDe\Tests\BillbeeAPI\": "tests/" } }, "scripts": { "fix-cs": [ "php-cs-fixer fix ./src/ --using-cache=no --rules=@PSR2", "php-cs-fixer fix ./tests/ --using-cache=no --rules=@PSR2" ], "analyse": "phpstan analyse" }, "archive": { "exclude": [ "/tests", "/doc" ] } }

devtronic commented 2 years ago

That's the composer.json of the SDK. I need a striped down version of the composer.json + the caller code to the SDK from your project. I need to reproduce the issue.

Goldfischpeter commented 2 years ago

Did you get setup?

devtronic commented 2 years ago

Did you get setup?

I'll take look at it today.

devtronic commented 2 years ago

I can't reproduce the problem. I followed the steps described in the Docs and it works as expected:

git clone https://github.com/billbeeio/billbee-php-sdk.git
cd billbee-php-sdk
git checkout tags/v2.1.0
composer install --no-dev --optimize-autoloader
mkdir sdk-dist

# On Windows:
move vendor\autoload.php sdk-dist
move src sdk-dist/src
move vendor sdk-dist/vendor

# Open the sdk-dist\autoload.php and replace
# require_once __DIR__ . '/composer/autoload_real.php';
# with
# require_once __DIR__ . '/vendor/composer/autoload_real.php';

Example Script:

<?php

use BillbeeDe\BillbeeAPI\Client;
use BillbeeDe\BillbeeAPI\Response;

require_once __DIR__ . '/sdk-dist/autoload.php';

$user = 'Your Billbee username';
$apiPassword = 'Your Billbee API Password'; // https://app.billbee.io/de/settings/api
$apiKey = 'Your Billbee API Key';

$client = new Client($user, $apiPassword, $apiKey);
$client->enableBatchMode(); # Enable batching

$client->products()->getProducts(1, 1); # Adds the request to the batch pool / returns null
$client->orders()->getOrders(1, 1); # Adds the request to the batch pool / returns null
$client->events()->getEvents(1, 1); # Adds the request to the batch pool / returns null

$results = $client->executeBatch(); # Results contain all responses in the added order

/** @var Response\GetProductsResponse $productsResult */
$productsResult = $results[0];

/** @var Response\GetOrdersResponse $ordersResult */
$ordersResult = $results[1];

/** @var Response\GetEventsResponse $eventsResult */
$eventsResult = $results[2];