PHPackages                             botk/core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. botk/core

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

botk/core
=========

Super lightweight classes and tools for developing RDF gateways

9.0.1(10mo ago)51.2k23MITPHPPHP &gt;=8.2

Since Jan 28Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/linkeddatacenter/BOTK-core)[ Packagist](https://packagist.org/packages/botk/core)[ Docs](https://github.com/linkeddatacenter/BOTK-core)[ RSS](/packages/botk-core/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (8)Dependencies (1)Versions (43)Used By (3)

[![logo](https://camo.githubusercontent.com/19376c3797b68e34c42c647c5bd0500fd2cb3e316f9aa8eb3097c75c3e62e5b7/687474703a2f2f6c696e6b6564646174612e63656e7465722f7265736f75726365732f76342f6c6f676f2f4c6f676f2d636f6c6f72692d74726173705f6f72697a2d363430783232302e706e67)](https://camo.githubusercontent.com/19376c3797b68e34c42c647c5bd0500fd2cb3e316f9aa8eb3097c75c3e62e5b7/687474703a2f2f6c696e6b6564646174612e63656e7465722f7265736f75726365732f76342f6c6f676f2f4c6f676f2d636f6c6f72692d74726173705f6f72697a2d363430783232302e706e67)

BOTK\\Core
==========

[](#botkcore)

[![Build Status](https://camo.githubusercontent.com/06d4732d12037e26cdf11f93a7e25ace4abff27b8c2cbbaef6f1eca465a9d315/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c696e6b65646461746163656e7465722f424f544b2d636f72652e7376673f7374796c653d666c61742d737175617265)](http://travis-ci.com/linkeddatacenter/BOTK-core)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/65d9cf37f6c4dbde31c15192e5a5d2e8b02593ccf1483d088ec1f7afb3dd27c2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c696e6b65646461746163656e7465722f424f544b2d636f72652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/linkeddatacenter/BOTK-core/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/a9848aff61615d00caf11383a2b2eb1addcb1270ec538a14495452bf8bc865b4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c696e6b65646461746163656e7465722f424f544b2d636f72652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/linkeddatacenter/BOTK-core)[![Latest Version](https://camo.githubusercontent.com/17c95da3dbb3098fb22ff9ad3473d7d533fdbcf54dedfa3b8c5a6419cfa97f38/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626f746b2f636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/botk/core)[![Total Downloads](https://camo.githubusercontent.com/c7f3995b5db79a9025187703faa8dd701d0f5e60e67e4ba2b09aa908ae4c26ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626f746b2f636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/botk/core)[![License](https://camo.githubusercontent.com/8fadcab8c570aeac24754b206eb827940d6f815cd3ecfe38cf8993537f09df4c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626f746b2f636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/botk/core)

Super lightweight base classes for developing smart gateways to populate RDF knowlege base.

> **This package approaching EOL - will be archived on 2025 Q4**

Installation
------------

[](#installation)

The package is available on [Packagist](https://packagist.org/packages/botk/core). You can install it using [Composer](http://getcomposer.org):

```
composer require botk/core

```

Overview
--------

[](#overview)

This package provides some simple tools to transform raw data into rdf linked data.

This package is compatible with [LinkedData.Center SDaaS architecture](http://linkeddata.center/home/sdaas)

It provides:

- a set of libraries to help gateways development
- a set of libraries to help reasoners development

Libraries usage
---------------

[](#libraries-usage)

The goal of the libraries is to simplify the conversion of raw data (e.g. .csv or xml file) in RDF. There are tons of tools to do this job and this is yet another. The idea is just to use PHP to do trivial data conversion instead to build and configure complex tool.

With BOTK you define simple models to describe things with a plain set of properties ( e.g a Business Entity, a contact, a product). Then a FactFactory processor cleans data and translates attributes in a RDF graph according with BOTK language profile. More or less this is what you have to do do when process csv or excel files row by row.

With BOTK libraries it is easy to create "gateways" ie processors that get in stdin a data stream producing in sdout a RDF turtle stream

For example this code snippet:

```
$options = [
    'factsProfile' => [
        'model' => 'SampleSchemaThing',
        'modelOptions' => [
            'base' => [ 'default'=> 'urn:yp:registry:' ]
        ],
        'datamapper'	=> function($rawdata){
            $data = array();
            $data['identifier'] = $rawdata[0];
            $data['homepage'] =  $rawdata[1];
            $data['alternateName'] = [ $rawdata[2], $rawdata[3]] ;
            return $data;
        },
        'rawdataSanitizer' => function( $rawdata){
            return (count($rawdata)==4)?$rawdata:false;
        },
     ],
    'skippFirstLine'	=> true,
    'fieldDelimiter' => ','
];

BOTK\SimpleCsvGateway::factory($options)->run();
```

processes this csv dataset:

```
 id,url,name,aka
 1,http://linkeddata.center/,LinkedData.Center,LDC
 2,https://github.org/,GitHub,

```

and produces something similar to this RDF turtle file:

```
@prefix schema:  .

	schema:alternateName "LDC","LinkedData.Center" ;
    schema:url  .

	schema:alternateName "GitHub" ;
    schema:url  .

```

The the dataset processing is driven by the SimpleCsvGateway class that uses a set of options that you can override:

SimpleCsvGateway optiondefaultnotemissingFactsIsErrortrueif a missing fact should considered an errorbufferSize2000skippFirstLinetruefieldDelimiter','factsProfilearray ...see below**factsProfile** are processed by FactsFactory class that uses following options:

factsProfile optiondefaultnotemodelLocalBusinessif no namespace specified BOTK\\Model is usedmodelOptionsarray ...see belowentityThreshold100in numbers of entity that trigger error resilence computationresilienceToErrors0.3if more than 30% of error throws a TooManyErrorExceptionresilienceToInsanes0.9if more than 90% of unacceptable data throws a TooManyErrorExceptionsource''the dataset source urldatamapperfunction\*\* YOU must provide at least this function \*\*dataCleanerfunctiona function to clean fields, by default removes ampty fieldsfactsErrorDetectorfunctiona function that detects logical errors in facts, by default reurne false (i.e. error) if no rdf triples generatedrawdataSanitizerfunctiona function that pre-validate raw data before processing, can be used as a filter**modelOptions** override the default field options provided by the selected model in the $DEFAULT\_OPTIONS variable. For example see this code snippet extracted from [Thing model](src%5CModel%5CThing.php) that is a superclass of [LocalBusiness model](src%5CModel%5CLocalBusiness.php)

Configuring models Options you can force field clenacing and validation.

```
...
	'uri' => array(
		'filter'    => FILTER_CALLBACK,
		'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
		'flags'  	=> FILTER_REQUIRE_SCALAR
	),
	'base' => array(
		'default'	=> 'urn:local:',
		'filter'    => FILTER_CALLBACK,
		'options' 	=> '\BOTK\Filters::FILTER_VALIDATE_URI',
		'flags'  	=> FILTER_REQUIRE_SCALAR
	),
	'id' => array(
		'filter'    => FILTER_CALLBACK,
		'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_ID',
		'flags'  	=> FILTER_REQUIRE_SCALAR
	),
	'page' => array(
		'filter'    => FILTER_CALLBACK,
		'options' 	=> '\BOTK\Filters::FILTER_SANITIZE_HTTP_URL',
		'flags'  	=> FILTER_FORCE_ARRAY
	),
...
```

a field definition drives the process of data cleansing and rdf generation that is provided by model implementation. Note that not always a field generate just a RDF triple: sometime the rdf generation processing requires to create blank nodes or to reference named node. For named node generation the 'base' uri namespace is normally used ("urn:local:." by default)

See [more examples here](tests/system/gateways).

Contributing to this project
----------------------------

[](#contributing-to-this-project)

See [Contributing guidelines](CONTRIBUTING.md)

License
-------

[](#license)

Copyright © 2018-2021 by [LinkedData.Center](http://LinkedData.Center/)®

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance53

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 92.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~88 days

Recently: every ~414 days

Total

40

Last Release

323d ago

Major Versions

4.0.1 → 5.0.02016-01-28

5.1.1 → 6.0.02017-02-15

6.4.0 → 7.0.02017-08-12

7.6.1 → 8.0.02020-02-19

8.3.0 → 9.0.02023-05-21

PHP version history (8 changes)4.0.0PHP &gt;=5.3

5.0.0PHP &gt;=5.5.0

6.0.0PHP &gt;=5.6

7.2.0PHP &gt;=7.0

7.6.0PHP ^7.1.3

8.0.0PHP ^7.3

8.2.5PHP &gt;=7.3

9.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/cdabb6f1a7cc46c4a299c684f66c7e3ae2fda117fe4db45758c01fe24d66221b?d=identicon)[botk](/maintainers/botk)

---

Top Contributors

[![ecow](https://avatars.githubusercontent.com/u/5788689?v=4)](https://github.com/ecow "ecow (112 commits)")[![miahmohd](https://avatars.githubusercontent.com/u/24657294?v=4)](https://github.com/miahmohd "miahmohd (9 commits)")

---

Tags

RDFLinked Dataopen dataBOTKKEES

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/botk-core/health.svg)

```
[![Health](https://phpackages.com/badges/botk-core/health.svg)](https://phpackages.com/packages/botk-core)
```

###  Alternatives

[easyrdf/easyrdf

EasyRdf is a PHP library designed to make it easy to consume and produce RDF.

62231.5M42](/packages/easyrdf-easyrdf)[sweetrdf/easyrdf

EasyRdf is a PHP library designed to make it easy to consume and produce RDF.

261.3M11](/packages/sweetrdf-easyrdf)[semsol/arc2

ARC2 is a PHP library for working with RDF. It also provides a MySQL-based triplestore with SPARQL support.

334250.0k15](/packages/semsol-arc2)[pietercolpaert/hardf

A fast parser for RDF serializations such as turtle, n-triples, n-quads, trig and N3

37141.1k9](/packages/pietercolpaert-hardf)[digitalbazaar/json-ld

A JSON-LD Processor and API implementation in PHP.

28555.4k1](/packages/digitalbazaar-json-ld)[lobostome/furry-bear

A PHP wrapper for various open data

19243.3k](/packages/lobostome-furry-bear)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
