Skip to content


Switch branches/tags

Latest commit

* php-cs-fixer: added further files

* updated README to show Github action status badges instead of travis + coveralls

+ further refinements

* further coding style issue fixes in tests/

* first step towards SQLite support

* prepered basic classes
* copied ARC2_StoreTableManager to provide create table
  functions for SQLite instead

* further preparations to allow SQLite; many refinements

+ moved Adapter tests to tests/integration
+ removed further @'s before functions

* github actions: added dedicated SQLite case

* removed StoreTest::testProcessTables

because it fails local but not in CI

* added further checks before run mysql related tests

* removed Makefile and simplified phpunit.xml

* SQLite compatibility: further improvements

* fixed/adapted further tests

only failures left

* added a var_dump to ARC2_ClassTest

to see why SQLite tests are failing

* tests/bootstrap.php: fixed mysqli-if clause

* reworked tests/bootstrap.php to either custom config or only predefined values

but not both

* tests/bootstrap.php: check $_SERVER vor env vars too

* github actions: reworked test approach

* github actions: fixed wrong php-reference

* SQLite related refinements in bootstrap.php

* tests/bootstrap: fixed outdated variable

* tests/bootstrap.php: fixed misspelling in $dbConfig['db_pdo_protocol']

* further fixes in test environment

* ARC2_ClassTest: removed var_dump

* re-added remaining MariaDB test cases (10.2-10.5)

* renamed PDOSQLite to PDOSQLiteAdapter; enabled further tests

* updated, added MySQL 5.6 to tests

* added var_dump to bootstrap.php again

* CachedPDOAdapterTest added check for dbConfig['db_pdo_protocol']

to avoid index access problems

* another small fix for CachedPDOAdapterTest

* force PDOSQLiteAdapterTest to use SQLite config

* fixed array access problem in PDOSQLiteAdapterTest

* for mysqli: fixed PDOSQLiteAdapterTest configuration usage

* fixed further SQLite related test problems

* SQLite: fixed relational expression SQL

* made SelectQueryTest::testSelectLeftJoinUsingOptional more clear

* added var_dump to find out why testReplace is failing


* added further echos to debug

* removed all workflow files except for SQLite to get faster test results

the problem is that I can't reproduce the error locally.

* made ARC2_StoreTest::testSetup to do an assertion

* hopefully fixed ARC2_StoreTest::getGraphs

problem was, it missed table prefix in some cases

* re-added ALL workflow files; enabled all SQLite tests

* removed debug output

* fixed mysql 5.6 workflow (used 5.7 too)

* added mysql 5.5 workflow

* updated status for mysql 5.5

* added MySQL 5.5 test status badge

* added section for new in-memory store

Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Latest Stable Version Total Downloads Latest Unstable Version License

ARC2 is a PHP 7.2+ library for working with RDF. It also provides a MySQL-based triplestore with SPARQL support. Older versions of PHP may work, but are not longer tested.

Test status:

Database Status
MariaDB 10.1
MariaDB 10.2
MariaDB 10.3
MariaDB 10.4
MariaDB 10.5
MySQL 5.5
MySQL 5.6
MySQL 5.7


For the documentation, see the Wiki. To quickly get started, see the Getting started guide.


Package available on Composer.

You should use Composer for installation:

composer require semsol/arc2:^2

Further information about Composer usage can be found here, for instance about autoloading ARC2 classes.



7.2 7.3 7.4 8.0
👍 👍 👍 👍

Database systems

This section is relevant, if you wanna use database related functionality.


5.5 5.6 5.7 8.0
👍 👍 👍 💥 (1)


10.0 10.1 10.2 10.3 10.4 10.5
(2) 👍 👍 👍 👍 👍

(1) As long as ARC2 uses mysqli, a connection to MySQL Server 8.0 is not possible. For more information, please look here.

(2) Not tested anymore, because outdated version.

RDF triple store

SPARQL support

Please have a look into to see which SPARQL 1.0/1.1 features are currently supported.

In-Memory store (SQLite-based)

Using MySQL as database backend is the default way. But you don't need MySQL, SQLite is enough to get a non-persistent in-memory store. Use the following example code to get a ready-to-use store instance.

// get a working ARC2_Store instance (with SQLite adapter)
$store = ARC2::getStore(['db_adapter' => 'pdo', 'db_pdo_protocol' => 'sqlite']);

// add 1 triple to the store
$store->query('INSERT INTO <> { <http://s> <http://p1> "baz" . }');

// send a SPARQL query to the store
$result = $store->query('SELECT * FROM <> WHERE {<http://s> <http://p1> ?o.}');

// you should get an array of array's with one entry in $result['result']['row'].

// remember, after your script finished, all data in $store is gone

Use cache

The RDF store implementation provides a hash-based query cache. It works on two levels: SQL and SPARQL, which means, that it checks given SPARQL queries as well as internally generated SQL queries.

To use it, just add the following to the database configuration:

$store = ARC2::getStore(array(
    'db_name' => 'testdb',
    'db_user' => 'root',
    'db_pwd'  => '',
    'db_host' => '',
    // ...
    'cache_enabled' => true // <== activates cache

Per default it uses a file based cache, which stores items in the default temp folder of the system (in Linux its usually /tmp). But you can use another cache solution, such as memcached.

PSR-16 compatibility

Our cache solution is PSR-16 compatible, which means, that you can use your own cache instance. To do that, add the following to the database configuration:

$store = ARC2::getStore(array(
    'db_name' => 'testdb',
    'db_user' => 'root',
    'db_pwd'  => '',
    'db_host' => '',
    // ...
    'cache_enabled' => true
    'cache_instance' => new ArrayCache() // <=== example Cache instance, managed by yourself

ARC2 uses Symfony Cache , which provides many connectors out of the box (Overview).

Known problems/restrictions with database systems

In this section you find known problems with MariaDB or MySQL, regarding certain features. E.g. MySQL 5.5 doesn't allow FULLTEXT indexes in InnoDB. We try to encapsulate any differences in the DB adapters, so that you don't have to care about them. In case you run into problems, this section might be of help.

MySQL 8.0 and mysqli

Using mysqli with MySQL 8.0 as backend throws the following exception:

mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password]

Based on this source, one has to change the my.cnf, adding the following entry:

[mysqld] default-authentication-plugin=mysql_native_password

Internal information for developers

Please have a look here to find information about maintaining and extending ARC2 as well as our docker setup for local development.