PHP code example of apirelio / nette

1. Go to this page and download the library: Download apirelio/nette 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/ */

    

apirelio / nette example snippets


use Apirelio\Nette\ApirelioManager;

final class InvoiceService
{
    public function __construct(private ApirelioManager $apirelio) {}

    public function create(): void
    {
        $this->apirelio->addMetadata(['region' => 'eu-central']);
        $this->apirelio->setErrorCode('VALIDATION_FAILED');
    }
}

$apirelio->track(
    event: 'invoice.created',
    integration: 'fakturoid',
    metadata: ['region' => 'eu-central'],
);

use Nette\Application\Request;
use Apirelio\Nette\Contracts\CustomerResolver;
use Apirelio\Nette\Data\ApirelioCustomer;

final class CurrentCustomerResolver implements CustomerResolver
{
    public function resolve(Request $request): ?ApirelioCustomer
    {
        return new ApirelioCustomer('customer_42', 'Acme Europe', 'growth');
    }
}