This example shows you how to:


Install the PHP logger

We recommend Monolog, which is what the Intacct SDK for PHP uses. At minimum, you should use a PSR7 interface.

  1. Update the composer.json for your project to include the logger:

        "require-dev": {
          "monolog/monolog": "1.21.0"
  2. In a terminal window, run composer require monolog/monolog' in the directory containing your composer.json file.

    This adds the Monolog library to your project (in vendor/monolog).

Learn about using logging

  1. Open LoggingExample.php and note the code that sets up logging.

    • A log file called intacct.html is created if it doesn’t already exist.
    • A Monolog StreamHandler that writes to that file is created.
    • The StreamHandler will use an HTML formatter.
    • A Monolog Logger named intacct-sdk-php-examples is created and is passed the StreamHandler.
    $log_path = fopen(__DIR__ . '\intacct.html', 'a+');
    $log_handle = new StreamHandler($log_path);
    $log_handle->setFormatter(new Monolog\Formatter\HtmlFormatter());
    $logger = new Logger('intacct-sdk-php-examples');
  2. Look at the code that passes the logger to the IntacctClient instance.

    $client = new IntacctClient([
        'profile_file' => __DIR__ . '\.intacct\credentials.ini',
        'logger' => $logger,

    Note: The default logging level for the Intacct SDK for PHP is DEBUG (100). To override this, use the log_level parameter, such as 'log_level' => 400.

Run the program and examine the log file

The program includes an error that will cause a transaction to be rolled back. Let’s take a look at this before running the code.

  1. Look at the code that specifies the object type to query. Note that the provided name is incorrect – it should be GLENTRY:

  2. Also note that the request is executed as a transaction (second parameter is true).

    $response = $client->execute($content, true, '', false, []);
  3. Run the program in your IDE then open intacct-sdk-php-examples/.intacct.html and look at the results generated by the logger:

Provide feedback