php11.0.0
What's Changed
This is a major release and may break your code. Please read the full changelog before upgrading.
- Change to HTTP API: This release changes the underlying protocol used by the SDK from Websockets to HTTP.
- No
Connect()
needed: Since the SDK now uses HTTP, it is stateless and does not require a connection to be established. - Async API: The SDK now uses a fully async API. All methods now return non-blocking
Amp\Future
's that you can call->await()
on instead. - Method calls: Even though the SDK is now async over HTTP the method signatures are mostly the same. Please take a look at the PHP SDK examples.
- Documentation: Please take a look at the method documentation in the
Vaas
class here.
How to migrate
To scan a file, you previously had to proceed as follows:
$authenticator = new ClientCredentialsGrantAuthenticator(
getenv("CLIENT_ID"),
getenv("CLIENT_SECRET"),
getenv("TOKEN_URL") ?: "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
);
$vaas = new Vaas(
getenv("VAAS_URL") ?? "wss://gateway.production.vaas.gdatasecurity.de"
);
$vaas->Connect($authenticator->getToken());
$scanPath = getenv("SCAN_PATH");
$vaasVerdict = $vaas->ForFile($scanPath);
fwrite(STDOUT, "Verdict for $vaasVerdict->Sha256 is " . $vaasVerdict->Verdict->value . " \n");
With the new SDK, you can now scan a file like this:
$authenticator = new ClientCredentialsGrantAuthenticator(
clientId: getenv("CLIENT_ID"),
clientSecret: getenv("CLIENT_SECRET"),
tokenUrl: getenv("TOKEN_URL")
);
$vaas = Vaas::builder()
->withAuthenticator($authenticator)
->build();
$scanPath = getenv("SCAN_PATH");
$vaasVerdict = $vaas->forFileAsync($scanPath)->await();
fwrite(STDOUT, "Verdict for $vaasVerdict->sha256 is " . $vaasVerdict->verdict->value . " \n");
Full Changelog: php10.0.1...php11.0.0