Skip to content


Switch branches/tags

Latest commit


Git stats


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

JSON Table

Scrutinizer Code Quality Code Coverage Build Status Dependency Status

A validator and storage library using the JSON table schema written in PHP.

This is a great utility library for validating that CSV files, streams or any other data source validates against a predefined JSON table schema definition.


Although this library has many great features, it does not (yet) adhere to the entire JSON table schema specification.

Currently the parts of the specification that are NOT supported are:

  1. Formats:

    • array
    • binary (this is just validated as a string)
    • geopoint
    • geojson
  2. Constraints currently there is no support for constraints.

  3. Foreign Keys

    The same schema structure is accepted but with the following considerations: * "datapackage" MUST be "postgresql". * "resource" MUST be the name of the table to use with optional schema qualifier. I.E. "import.t_table_name". * "fields" follow the JSON table schema specification but refer to the fields in the database table.


This library was written to fulfill a need for Halo a commercial client management system maintained by Footwork Solutions Ltd.

It is used to validate and store data as part of a import tool for users of Halo.

We use a lot of open source projects at Footwork Solutions and this project, along with our other open source work is our way of giving back to the community we appreciate so much.


See the examples directory for a detailed run through of how to validate and store a CSV file.

Quick Start

Validate a CSV file:

// Instantiate the analysis class.
$lo_analyser = new \JsonTable\Analyse();

// Let the analyser know where the JSON table schema is.

// Let the analyser know where the CSV file to validate is.

// Check whether the file is valid against the schema.
$lb_file_is_valid = $lo_analyser->validate();

Store the valid CSV file:

$lo_store = \JsonTable\Store::load('postgresql');
$lb_file_is_stored = $lo_store->store('your_table_name');


composer require footwork_solutions/json_table

Implementation Notes

  • datetime; date; time - fmt:[PATTERN] - This supports PHP date formats @see
  • datetime; date; time - ISO8610 - The following formats are validated without specifing a format:
    • Combined date and time in UTC: 2015-03-09T13:07:04Z
    • Date: 2015-03-09
    • Time: hh:mm:ss
  • Given the range of options that match the ISO8610 format, we recommend that you always specify a format.
  • Pattens: A delimiter must be included in the regex.
  • Column name checking is case insensitive.
  • Foreign keys with a single field can be omitted from the CSV and the foreign key check will be ignored. However, foreign keys with multiple fields must have all those fields in the CSV file.


Bugs & Feature Requests

Please use the issue tracker to report any bugs or request new features.


Pull Requests are always welcome.

Please ensure that your code meets the PSR-1, PSR-2 and PSR-4 standards.

  1. Fork the repository.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes.
  4. Push to the branch (git push origin my-new-feature).
  5. Create a new Pull Request.


This is free software distributed under the terms of the MIT license. See LICENCE for the full details.


PHP implementation of the JSON table schema







No packages published