Verwendung

1. Bibliothek in composer.json einbinden

{
    "require": {
        "locr/poi-client-v2": "^1.0"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://x-token-auth:<secret-auth-token>@bitbucket.org/locr/php-poi-client-v2.git"
        }
    ]
}

2. Composer mit neu hinzugefügter Bibliothek aktualisieren

$ composer update

3. Beispiele für die Verwendung der Bibliothek im Code

3.1. Allgemeine Datenbank Infos holen

<?php

declare(strict_types=1);

use Locr\Lib\PoiClientV2\Services\{Config, PoiService};

$config = Config::factory();
$poiService = new PoiService(config: $config);
$dbInfo = $poiService->getDatabaseInfo(nameOrUUID: 'default');
if (is_null($dbInfo)) {
    print 'Database not found.' . PHP_EOL;
    exit(1);
}

print 'Name:' . $dbInfo->Name . PHP_EOL; // default
print 'Description:' . $dbInfo->Description . PHP_EOL; // Default POI database
print 'Created:' . $dbInfo->Created->format('Y-m-d H:i:s') . PHP_EOL; // 2023-10-01 12:00:00
print 'Uuid:' . $dbInfo->Uuid . PHP_EOL; // 123e4567-e89b-12d3-a456-426614174000

3.2. Boundings einer Datenbank holen

<?php

declare(strict_types=1);

use Locr\Lib\PoiClientV2\Services\{Config, PoiService};

$config = Config::factory();
$poiService = new PoiService(config: $config);
$boundings = $poiService->calculateBoundings(nameOrUUID: 'default');
if (is_null($boundings)) {
    print 'Database not found.' . PHP_EOL;
    exit(1);
}

print 'LatitudeMin: ' . $boundings->LatitudeMin . PHP_EOL; // 50.1234
print 'LatitudeMax: ' . $boundings->LatitudeMax . PHP_EOL; // 52.4321
print 'LongitudeMin: ' . $boundings->LongitudeMin . PHP_EOL; // 10.1234
print 'LongitudeMax: ' . $boundings->LongitudeMax . PHP_EOL; // 12.4321

3.3. Eine bestimmte .env Datei laden

<?php

declare(strict_types=1);

use Locr\Lib\PoiClientV2\Implementations\EnvironmentConfigLoader;
use Locr\Lib\PoiClientV2\Services\{Config, PoiService};

$config = Config::factory(configLoaders: [
    new EnvironmentConfigLoader(dotEnvFile: $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '.env'),
]);
$poiService = new PoiService(config: $config);

// ...