Download the PHP package trevol/trevol-php without Composer

On this page you can find all versions of the php package trevol/trevol-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 trevol-php

trevol/trevol-php

SDK de PHP para la API de Trevol: facturación electrónica, documento soporte, documento equivalente, nómina electrónica y eventos RADIAN ante la DIAN (Colombia). Documentación: https://platform.trevol.si/docs.

In English. PHP SDK for the Trevol API (Colombian e-invoicing, DIAN). PHP ≥ 8.2, Guzzle 7. Typed models and API clients generated from the OpenAPI spec (OpenAPI Generator, namespace Trevol\Generado), plus a thin hand-written layer (namespace Trevol): automatic Idempotency-Key (the same one on retries), retries with exponential backoff honouring Retry-After, typed exceptions by problem+json code, environment inferred from the key prefix (tvl_test_ = DIAN test environment, tvl_live_ = production), pinned Trevol-Version, Standard Webhooks signature verification, cursor pagination with generators and PDF/XML/ZIP downloads. Docs are in Spanish like the API.

Versión 0.1.0 — API 2026-10-22. Licencia MIT.

Instalación

Necesita PHP 8.2 o más nuevo, ext-curl, ext-json y ext-mbstring. Depende de Guzzle 7 y de la biblioteca abierta standard-webhooks/standard-webhooks (MIT).

Uso

La llave de la API se crea en la consola de desarrolladores (https://platform.trevol.si/llaves) y se guarda en el entorno de tu servidor: TREVOL_API_KEY. Una llave tvl_test_… llama a la habilitación de la DIAN; una tvl_live_…, a producción. El SDK deduce el entorno del prefijo ($trevol->environment).

Los nombres de los métodos son los del operationId de la especificación (createInvoice, listInvoices, retrieveInvoice, correctInvoice, sendInvoice, downloadInvoicePdf…). Usa argumentos con nombre: el orden posicional de los parámetros lo decide el generador y puede cambiar si la API suma un filtro opcional; los nombres no. El cuerpo es un arreglo con las claves iguales a las de la API (external_id) o el modelo generado (new \Trevol\Generado\Model\InvoiceInput([...])); los importes y las fechas viajan como texto ('32000.50', '2026-10-31'). Un objeto JSON vacío se escribe (object) [].

Lo que conviene saber

Idempotencia: manda external_id y tu propia clave

El SDK genera una Idempotency-Key por llamada y la repite en todos los reintentos de esa llamada. Pero si tu proceso muere y vuelves a llamar, saldrá otra clave y, si no mandaste external_id (es opcional), podría duplicarse el documento. Por eso:

Ante un ConflictException con getTrevolCode() === 'external_id_in_use', el documento ya existe: usa $e->getProblem()['existing_id']. Toda excepción lleva la clave que se usó (getIdempotencyKey()) para reintentar más tarde con la misma. Un ApiConnectionException también.

Respuestas 202 (processing, sending, validating, contingency)

No son errores ni se reintentan: se devuelven como el modelo de la respuesta. No crees otro documento: espera el webhook o consulta con retrieveInvoice; repetir la misma llamada con la misma Idempotency-Key continúa el mismo documento. El PDF y el ZIP llegan después del 201 (evento invoice.delivered, o delivery.status === 'completed').

Reintentos

Hasta 2 reintentos (3 intentos) con espera creciente (0,5 s, 1 s, 2 s… con tope de 8 s y un poco de azar) ante un error de red, 429, 500, 502, 503, 504, un 409 request_in_progress o previous_event_pending, y todo problema que diga retryable: true (salvo el 402). Respeta Retry-After; si pide más de maxRetryAfter (60 s) no espera y lanza la excepción con getRetryAfter(). Las operaciones sin Idempotency-Key (crear un endpoint, …/send, DELETE) solo se reintentan con 429. Los 202 y los errores finales (400, 401, 402, 403, 404, 422 y los 409 invalid_state, external_id_in_use, duplicate_document) nunca se reintentan. Las esperas son bloqueantes (usleep), también en los métodos …Async.

La versión de la API

El SDK fija Trevol-Version: 2026-10-22 en cada petición. Ojo: una llave creada con la versión 2026-10-21 que empiece a usar este SDK pasa a 2026-10-22 (el encabezado manda): recibe 202 processing donde antes recibía 503. Si todavía no quieres ese cambio: new Trevol($llave, apiVersion: '2026-10-21'). Más en https://platform.trevol.si/docs/versiones.

Excepciones tipadas

TrevolException es la base (Trevol\Exception\*); las clases salen del code del problem+json: AuthenticationException, PermissionDeniedException, NotFoundException, InvalidRequestException, IdempotencyException, ValidationException (con getErrors(): field, pointer, message), ConflictException, PreconditionException, DianRejectedException (con getProblem()['document'] y ['rules']), BalanceException, RateLimitException, DianUnavailableException e InternalServerException. Un code que el SDK todavía no conoce llega como TrevolException con ese getTrevolCode(): nunca rompe. Además: ApiConnectionException (no hubo respuesta), ConfigurationException (mal uso, antes de llamar) y WebhookVerificationException (getReason(): firma, fecha, cabeceras o cuerpo). Cada excepción tiene getStatus(), getTrevolCode(), getType(), getTitle(), getDetail(), getRequestId(), isRetryable(), getRetryAfter(), getErrors(), getIdempotencyKey(), getProblem() (el cuerpo completo) y getResponseHeaders(). Ninguna incluye tu llave (el parámetro $apiKey va marcado #[\SensitiveParameter]: tampoco sale en un rastro de pila).

Webhooks

La firma se calcula sobre los bytes exactos: no uses el cuerpo ya decodificado. verify acepta las cabeceras en cualquier caja (getallheaders(), $request->headers->all(); recibe un arreglo: $request->headers a secas es un objeto HeaderBag y da TypeError); la firma esperada la calcula la biblioteca de Standard Webhooks, y el SDK tolera 5 minutos hacia atrás y hacia adelante en webhook-timestamp y compara en tiempo constante.

Estado y cabeceras de la respuesta

Cada método tiene una variante …WithHttpInfo que devuelve [modelo, estado, cabeceras]: [$factura, $estado, $cabeceras] = $trevol->invoices->createInvoiceWithHttpInfo(...); ($cabeceras['request-id'], idempotent-replayed).

Opciones

Cómo está hecho

Licencia

MIT © 2026 Joshua Montclair (Trevol).


All versions of trevol-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.3
guzzlehttp/psr7 Version ^1.7 || ^2.0
standard-webhooks/standard-webhooks Version ^1.0
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 trevol/trevol-php contains the following files

Loading the files please wait ...