Download the PHP package trisnawan/translator-client-php without Composer

On this page you can find all versions of the php package trisnawan/translator-client-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package translator-client-php

Translator Client for PHP

Client PHP tanpa dependensi (hanya curl) untuk REST API Translator — fokus pada alur asynchronous:

  1. Kirim permintaan terjemahan dengan Translator::translate() → POST /translate (autentikasi key_id + signature token).
  2. Terima hasilnya di webhook, sudah diverifikasi otomatis oleh Webhook::validData().

Kontrak API lengkap ada di API_DOC.md.

Persyaratan

Instalasi

Alur

1. Mengirim Terjemahan

translate() menandatangani request dengan secret_key lalu mengembalikan data dari API (history_id, status, callback_enabled, ...). Hasil terjemahan tidak dibalas di sini — hasilnya dikirim ke webhook Anda.

Bahasa bisa di-override per panggilan:

Parameter translate()

Parameter Wajib Keterangan
$driver ✅ id driver yang diberikan ke akun, mis. gemini-3.8-flash
$referenceId ✅ id milik Anda; diikat ke signature token dan dicocokkan saat callback
$referenceContent ✅ teks yang akan diterjemahkan
$from / $to – override bahasa; default dari constructor

Parameter constructor

Parameter Default Keterangan
$baseUrl – alamat API, mis. http://localhost:3000
$accountId – UUID akun pemilik API key (dipakai pada signature token)
$keyId – id pada account_keys
$secretKey – secret_key milik key tersebut
$from / $to null bahasa default untuk semua translate()
$tokenTtl 300 masa berlaku signature token (detik)
$timeout 30 timeout HTTP request (detik)

Jika callback_enabled bernilai false (key tanpa callback_url), hasil harus diambil manual lewat dashboard/GET /histories — di luar cakupan library ini.

2. Menerima Callback

Pasang endpoint webhook Anda sebagai callback_url pada API key, lalu verifikasi sekaligus baca payload-nya hanya dengan validData():

validData() secara otomatis memverifikasi:

Semua kegagalan melempar WebhookException; payload yang valid dikembalikan sebagai array.

Balas 2xx hanya jika tidak ada exception, karena selain itu server akan menjadwalkan ulang callback (default 5 menit, maksimal 2 percobaan).

Payload callback

Field Tipe Keterangan
status string translated atau failed
translate_from string kode bahasa sumber
translate_to string kode bahasa tujuan
reference_id string sama dengan yang dikirim saat translate()
translated_content string | null hasil terjemahan; null bila failed
translated_at string | null waktu selesai (ISO 8601)

Integrasi framework

validData() membaca $_SERVER + php://input. Bila framework Anda punya request sendiri, inject keduanya:

Nama header dicocokkan tanpa peduli bentuk dan huruf besar/kecil — key_id, Key-Id, maupun HTTP_KEY_ID sama-sama dikenali, jadi array mentah dari getallheaders() juga bisa di-inject sebagai $server.

Bila aplikasi Anda punya beberapa API key, baca header key_id lebih dulu untuk menentukan secret_key yang sesuai, baru panggil validData($keyId, $secretKey).

Penanganan Error

Exception Kapan muncul Info tambahan
TranslatorException base semua error library –
ApiException API membalas non-2xx (signature salah, driver tidak diberi akses, quota habis, broker down, ...) getStatusCode(), getErrors()
WebhookException callback tidak valid / tidak terautentikasi –

Lisensi

MIT — lihat LICENCE.txt.


All versions of translator-client-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package trisnawan/translator-client-php contains the following files

Loading the files please wait ...