PHP code example of mrcnpdlk / teryt-api

1. Go to this page and download the library: Download mrcnpdlk/teryt-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mrcnpdlk / teryt-api example snippets



    /**
     * Cache in system files
     */
    $oInstanceCacheFiles = new \phpFastCache\Helper\Psr16Adapter('files');



$oInstanceLogger = new \Monolog\Logger('name_of_my_logger');
$oInstanceLogger->pushHandler(new \Monolog\Handler\ErrorLogHandler(
        \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM,
        \Psr\Log\LogLevel::DEBUG
    )
);


use mrcnpdlk\Teryt\Client;
use mrcnpdlk\Teryt\NativeApi;
use mrcnpdlk\Teryt\Config;

$oConfig = new Config([
    'logger'       => $oInstanceLogger,
    'cache'        => $oInstanceCacheFiles,
    'username'     => 'my_login',
    'password'     => 'my_password',
    'isProduction' => true,
]);
$oNativeApi = NativeApi::create($oConfig);

var_dump($oNativeApi->CzyZalogowany());
var_dump($oNativeApi->PobierzSlownikCechULIC());
var_dump($oNativeApi->WyszukajMiejscowosc('skiernie',null));

$oApi = new \mrcnpdlk\Teryt\Api($oClient);
print_r($oApi->getCity('0700884'));