PHP code example of ankapix / logo-objects-php
1. Go to this page and download the library: Download ankapix/logo-objects-php 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/ */
ankapix / logo-objects-php example snippets
use LogoObjects\LogoClient;
$logo = new LogoClient([
'baseUrl' => 'http://SUNUCU_IP:32001/api/v1',
'username' => 'KULLANICI',
'password' => 'PAROLA',
'firmno' => '1',
'basicAuth' => 'BASE64_CLIENT_BILGISI', // base64("clientId:clientSecret")
]);
// LISTELEME — ApiResponse döner; items[] tipli nesnelerdir
$resp = $logo->salesOrders->getAll(['limit' => 10, 'sort' => ['DATE', 'desc']]);
foreach ($resp->items as $order) {
echo $order->DOCODE, ' - ', $order->NETTOTAL, PHP_EOL;
}
// TEK KAYIT
$order = $logo->salesOrders->getById(123);
// EKLEME / DÜZENLEME / SİLME
$logo->salesOrders->create([ /* ... */ ]);
$logo->salesOrders->update(123, [ /* ... */ ]); // PUT
$logo->salesOrders->patch(123, ['DOCODE' => 'X']); // PATCH
$logo->salesOrders->delete(123);
// SAYIM ve ARAMA
$count = $logo->salesOrders->getCount();
$results = $logo->salesOrders->search(['code' => 'AB', 'date' => ['gte' => '01.01.2026']]);
$logo->items->getAll([
'limit' => 50,
'fields' => ['CODE', 'NAME'],
'sort' => [['CODE', 'NAME'], 'desc'], // -> "CODE desc,NAME desc"
]);
$order = $logo->salesOrders->getById(123);
$order->TRANSACTIONS->items[0]->ITEMCODE; // iç içe satırlar da tiplidir
$array = $order->toArray();
use LogoObjects\Exception\LogoApiError;
use LogoObjects\Exception\ValidationError;
try {
$logo->salesOrders->create($payload);
} catch (ValidationError $e) {
echo $e->getMessage() . PHP_EOL;
// The request is invalid. (3 dogrulama hatasi): ~ kodlu indirim bulunamadı.[6]; ...
foreach ($e->getValidationErrors() as $err) { // tam liste (mesajda kırpılmış olabilir)
echo " - $err" . PHP_EOL;
}
foreach ($e->getModelState() as $alan => $hatalar) { // ['ValError0' => ['...'], ...]
echo " $alan: " . implode(', ', $hatalar) . PHP_EOL;
}
} catch (LogoApiError $e) {
echo "HATA (HTTP {$e->getStatusCode()}): {$e->getMessage()}" . PHP_EOL;
}
bash
composer
src/
├── LogoClient.php tüm endpoint client'larını taşıyan ana sınıf
├── Endpoints.php endpoint adı -> URL kaydı
├── Http/BaseApiClient.php cURL, OAuth2 token, buildQueryString
├── Support/Entity.php hydrate edilebilir taban DTO (fromArray/toArray)
├── Types/ ortak tipler (BaseEntity, ApiResponse, Meta, ...)
├── Utils/QueryBuilder.php OData sorgu üretimi
└── Clients/<Endpoint>/
<Endpoint>Client.php o endpoint'in CRUD + özel metotları
Types.php o endpoint'in nesne/satır tipleri (PHP sınıfları)