1. Go to this page and download the library: Download amateescu/prov 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/ */
> // These two lines describe DIFFERENT facts, even though both identifiers are the same:
> $builder->wasGeneratedBy('ex:article', 'ex:writing'); // article wasGeneratedBy writing ✓
> $builder->used('ex:article', 'ex:writing'); // article used writing ✗ (reversed)
>
> // Always use named arguments:
> $builder->wasGeneratedBy(entity: 'ex:article', activity: 'ex:writing');
> $builder->used(activity: 'ex:writing', entity: 'ex:article');
>
$json = new JsonSerializer(sortRecords: true)->serialize($doc);
// Or through the format enum, which also takes prettyPrint:
$json = Format::Json->createSerializer(sortRecords: true)->serialize($doc);
use Prov\Operation\DocumentOperations;
use Prov\Operation\DocumentComparator;
$merged = DocumentOperations::merge($docA, $docB);
$flat = DocumentOperations::flatten($docWithBundles); // throws if Mentions present
$flat = DocumentOperations::flattenDroppingMentions($docWithBundles);
DocumentComparator::equals($a, $b); // structural (semantic) equality
use Prov\Operation\ProvGraph;
$graph = new ProvGraph($document);
$graph->relationsFrom('ex:article'); // relations whose subject is ex:article
$graph->relationsTo('ex:writing'); // relations whose object is ex:writing
$graph->relationsReferencing('ex:plan'); // any endpoint, including secondary ones
$graph->generationsOf('ex:article'); // Generation records of an entity
$graph->usagesOf('ex:draft'); // Usage records of an entity
$graph->recordByIdentifier('ex:article'); // O(1) record lookup
$graph->agentsOf('ex:writing'); // agents associated with an activity
ProvGraph::referencedIdentifiers($relation); // every endpoint of one relation
use Prov\Scan\JsonScanner;
$scanner = new JsonScanner($json);
$scanner->ids('entity'); // record ids of a section
$scanner->attributeValue('entity', 'ex:article', 'dct:title'); // first value, as decoded
$scanner->stringValue('activity', 'ex:writing', 'ex:note'); // ?string
$scanner->intValue('activity', 'ex:writing', 'ex:exit_code'); // ?int
$scanner->dateTimeValue('activity', 'ex:writing', 'prov:startTime'); // ?DateTimeImmutable
$scanner->attributeBag('agent', 'ex:alice'); // Attributes, as on the deserialized record
$scanner->relations('used'); // ScannedRelation list: endpoints + attributes
$scanner->relationAttributeBag($relation); // a relation's annotations as Attributes
$scanner->relationsReferencing('ex:article'); // every relation naming an identifier
$scanner->agentsOf('ex:writing'); // agents, with their delegation chains
$result = Prov::validate($document);
if (!$result->isValid) {
foreach ($result->violations as $violation) {
echo "[C{$violation->constraintId}] {$violation->message}\n";
}
}
// Or throw if the document has any violations:
Prov::validate($document)->throwIfInvalid(); // raises ConstraintViolationException