Need a tiny clue regarding sdk-php

This is self-hosted.

I have a directory named /opt/integration

I ran: composer require invoiceninja/sdk-php in that directory.

I have a file named addCustomer.php that contains:

<?php

use InvoiceNinja\Config as NinjaConfig;
use InvoiceNinja\Models\Client;

NinjaConfig::setURL('https:/www.examplecom/in/api/v1');
NinjaConfig::setToken('xxxxxxxxxxxxxxxxxx');

$client = new Client('test@example.com');
$client->save();

?>

php addCustomer.php says:

PHP Fatal error:  Uncaught Error: Class 'InvoiceNinja\Config' not found in /opt/integration/addCustomer.php:7
Stack trace:
#0 {main}
  thrown in /opt/integration/addCustomer.php on line 7

Fatal error: Uncaught Error: Class 'InvoiceNinja\Config' not found in /opt/integration/addCustomer.php:7
Stack trace:
#0 {main}
  thrown in /opt/integration/addCustomer.php on line 7

AFAIK, the sdk is installed correctly: /opt/integration/vendor/invoiceninja/sdk-php/src/InvoiceNinja/Models contains all the various models (Client, etc.)

Can anybody tell me what I’m missing?

Is there a path I need to set somewhere?

This is self-hosted on Fedora. There is nothing in storage/logs/laravel-error log

Any help is appreciated.

Thanks!

Terry

PS. I realize I posted my token. I deactivated it and will generate a new one.

Try adding require DIR . '/vendor/autoload.php';

https://getcomposer.org/doc/01-basic-usage.md

Thanks!

require took care of it.

I had read the docs, but it wasn’t obvious that I needed the autoload section; I was assuming that the code from the https://github.com/invoiceninja/sdk-php page was enough to get a minimal test working.

Thanks for the help, I appreciate it.

Terry