Skip to content

PHP Quickstart

Work in progress

The contents of this page currently mirror the README file in the PHP SDK repository. For an up-to-date version, make sure to check the repository itself.

Interested?

Are you interested in a stand-alone Quickstart for your language? Let us know, or contribute one yourself!

Not receiving invoices in the live environment?

Ensure your correspondents use 7HD37X0 as the value of their invoices' Codice Destinatario field. That is how SDI knows they should be forwarded to the Invoicetronic API.

Installation & Usage

Requirements

PHP 7.4 and later. Should also work with PHP 8.0.

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/invoicetronic/php-sdk.git"
    }
  ],
  "require": {
    "invoicetronic/php-sdk": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

<?php
require_once('/path/to/Invoicetronic Invoice SDK/vendor/autoload.php');

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');



// Configure HTTP basic authorization: Basic
$config = Invoicetronic\Configuration::getDefaultConfiguration()
              ->setUsername('YOUR_USERNAME')
              ->setPassword('YOUR_PASSWORD');


$apiInstance = new Invoicetronic\Api\CompanyApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$page = 1; // int | Page number. Defaults to 1.
$page_size = 100; // int | Items per page. Defaults to 50. Cannot be greater than 200.

try {
    $result = $apiInstance->invoiceV1CompanyGet($page, $page_size);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CompanyApi->invoiceV1CompanyGet: ', $e->getMessage(), PHP_EOL;
}