If you use Composer to manage your dependencies the simplest and best way to manage your autoloading to is to load the autoload file generated by Composer and not the autoload files included in each package:
require __DIR__.'/vendor/autoload.php';
This will include the autoloader for all of your dependencies managed by Composer. Then you can call your use
statement and the rest of the code. I use __DIR__
to ensure I get the correct relative path when including that file. You may need to tweak your path to match your setup.
require __DIR__.'/vendor/autoload.php';
use authnet\AuthnetWebhook as AuthnetWebhook;
$headers = getallheaders();
$payload = file_get_contents("php://input");
$webhook = new AuthnetWebhook($signaturekey, $payload, $headers);
If you are not using Composer to manage your dependencies you will need to refer to the autoloader of each package directly like you are currently doing. But you still need to load it before you reference the code in that package.
require 'vendor/stymiee/authnetjson/src/autoload.php';
use authnet\AuthnetWebhook as AuthnetWebhook;
$headers = getallheaders();
$payload = file_get_contents("php://input");
$webhook = new AuthnetWebhook($signaturekey, $payload, $headers);