PHP code example of kraenzle-ritter / anton-import-format
1. Go to this page and download the library: Download kraenzle-ritter/anton-import-format 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/ */
kraenzle-ritter / anton-import-format example snippets
use KraenzleRitter\AntonImportFormat\Validator;
$validator = new Validator();
$result = $validator->validate($metadataJson); // string | array | stdClass
if ($result->valid) {
// proceed with import
} else {
foreach ($result->errors as $error) {
// each error has ->path, ->keyword, ->message
printf("[%s] %s: %s\n", $error->keyword, $error->path, $error->message);
}
}
final readonly class ValidationResult {
public bool $valid;
/** @var list<ValidationError> */
public array $errors;
public function toArray(): array; // for JSON-serialisation into ImportEvent / pipeline-result payloads
}
$result = $validator->validateWithVersionWarning($metadataJson);
// $result->errors may informational.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.