gianluca-pettenon / soap-totvs
Requires
- php: >=8.5
- laminas/laminas-soap: ^2.13
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-10 21:19:05 UTC
README
Requirements
PHP>=8.5Composer- Enabled
SOAPextension (php-soap)
Installation
Require the package in your project:
composer require gianluca-pettenon/soap-totvs
Configuration
Pass the host, user and password to SoapConfig. The fourth argument is extra SoapClient options and overrides the defaults (connection_timeout is 25 seconds).
use SoapTotvs\Adapters\LaminasAdapter; use SoapTotvs\Adapters\SoapConfig; use SoapTotvs\TotvsGateway; $gateway = new TotvsGateway( adapter: new LaminasAdapter(new SoapConfig( host: 'https://localhost:8051', user: 'user', password: 'secret', )) );
Usage Overview
The main entry point of this SDK is TotvsGateway, which exposes dedicated gateways for each web service:
query()– SQL Query Web Serviceprocess()– Process Web ServicedataServer()– DataServer Web Service
Example of basic bootstrap:
use SoapTotvs\TotvsGateway; use SoapTotvs\Adapters\LaminasAdapter; use SoapTotvs\Adapters\SoapConfig; $gateway = new TotvsGateway( adapter: new LaminasAdapter(new SoapConfig( host: 'https://localhost:8051', user: 'user', password: 'secret', )) );
SQL Query Web Service
affiliate is the coligada code. system is the RM system code (S for educational).
use SoapTotvs\TotvsGateway; use SoapTotvs\Adapters\LaminasAdapter; use SoapTotvs\Adapters\SoapConfig; $gateway = new TotvsGateway( adapter: new LaminasAdapter(new SoapConfig( host: 'https://localhost:8051', user: 'user', password: 'secret', )) ); $result = $gateway->query()->execute( sentence: 'Example.001', affiliate: 1, system: 'S', parameters: ['cdUser' => 1302] );
Process Web Service
use SoapTotvs\TotvsGateway; use SoapTotvs\Adapters\LaminasAdapter; use SoapTotvs\Adapters\SoapConfig; $gateway = new TotvsGateway( adapter: new LaminasAdapter(new SoapConfig( host: 'https://localhost:8051', user: 'user', password: 'secret', )) ); $result = $gateway->process()->execute( process: 'ProcessName', xml: '<Parameters></Parameters>' );
DataServer Web Service
context is the DataServer context (int or string, for example CODCOLIGADA=1;CODSISTEMA=S).
use SoapTotvs\TotvsGateway; use SoapTotvs\Adapters\LaminasAdapter; use SoapTotvs\Adapters\SoapConfig; $gateway = new TotvsGateway( adapter: new LaminasAdapter(new SoapConfig( host: 'https://localhost:8051', user: 'user', password: 'secret', )) ); // SaveRecord $save = $gateway->dataServer()->saveRecord( dataServer: 'DataServerName', context: 'CODCOLIGADA=1;CODSISTEMA=S', xml: '<Data></Data>' ); // ReadRecord $record = $gateway->dataServer()->readRecord( dataServer: 'DataServerName', context: 'CODCOLIGADA=1;CODSISTEMA=S', primaryKey: 123 ); // ReadView $view = $gateway->dataServer()->readView( dataServer: 'ViewName', context: 'CODCOLIGADA=1;CODSISTEMA=S', filter: 'FIELD = 1' );
Further Documentation
For details about specific parameters, constraints and behaviors of each web service, refer to the official TOTVS documentation.
Each gateway class contains a link to the corresponding TOTVS docs.