PHP code example of kraenzle-ritter / skos

1. Go to this page and download the library: Download kraenzle-ritter/skos 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 / skos example snippets


use KraenzleRitter\Skos\Concept;
use KraenzleRitter\Skos\ConceptScheme;
use KraenzleRitter\Skos\Format;
use KraenzleRitter\Skos\SkosWriter;
use KraenzleRitter\Skos\Vocabulary;

$vocabulary = new Vocabulary(
    new ConceptScheme('https://archive.example/keywords', titles: ['de' => 'Schlagwörter']),
    [
        new Concept('https://archive.example/id/writing', prefLabels: ['de' => 'Schrift']),
        new Concept(
            'https://archive.example/id/letter',
            prefLabels: ['de' => 'Brief', 'it' => 'lettera'],
            altLabels: ['de' => ['Schreiben']],
            broader: ['https://archive.example/id/writing'],
            exactMatch: ['http://www.wikidata.org/entity/Q133492'],
        ),
    ],
);

$turtle = (new SkosWriter)->write($vocabulary, Format::Turtle);
$branch = (new SkosWriter)->write($vocabulary->subtree('https://archive.example/id/writing'), Format::RdfXml);

use KraenzleRitter\Skos\SkosReader;
use KraenzleRitter\Skos\ThesaurusTable;

$result = (new SkosReader)->read(file_get_contents('ariadne.ttl'), Format::Turtle);
$vocabulary = $result->vocabulary();          // the only scheme, or name one
$warnings = $result->warnings;

$table = (new ThesaurusTable(new ConceptScheme('https://archive.example/thesaurus'), 'de'))->read($rows);
$table->vocabulary; $table->compounds; $table->warnings;