Self-hostable FAIR repo, designed for small-scale
Find a file
2025-08-16 14:47:26 -07:00
inc Cache all remote API calls (#38) 2025-08-15 16:17:33 -07:00
composer.json Initial export of the repository 2025-06-05 12:06:13 +02:00
LICENSE Add readme to explain what Mini FAIR is (#1) 2025-06-06 14:38:23 +01:00
plugin.php add plugin headers (#8) 2025-06-10 20:26:16 +01:00
README.md Add requirement for persistent object cache (#39) 2025-08-16 14:47:26 -07:00

Mini FAIR Repo

The Mini FAIR plugin transforms your site into a FAIR Repository, allowing you to serve packages directly from your own infrastructure into the FAIR system.

Design Goals

Mini FAIR is designed to allow plugin and theme vendors to host their own FAIR repository easily, integrating with tools theyre already using. Mini FAIR is built for small scale hosting for a few packages, not for general use as a mass-hosting repository.

We aim to make it possible for everyone to run Mini FAIR, with a focus on ease of use and integration with existing tooling.

Requirements

Local Installation & Development Setup

1. Clone the Repository

git clone https://github.com/fairpm/mini-fair-repo.git
cd mini-fair-repo

2. Install Dependencies

Install PHP dependencies using Composer:

composer install

This will install the required packages:

  • yocto/yoclib-multibase - For multibase encoding
  • simplito/elliptic-php - For elliptic curve cryptography
  • spomky-labs/cbor-php - For CBOR data format handling

3. WordPress Setup

Option A: Local WordPress Installation

  1. Set up a local WordPress environment using your preferred method:
  2. Copy the Mini FAIR plugin to your WordPress plugins directory:
    cp -r /path/to/mini-fair-repo /path/to/wordpress/wp-content/plugins/mini-fair
    
  3. Activate the plugin through the WordPress admin interface or via WP-CLI:
    wp plugin activate mini-fair
    

Option B: Using WP-CLI for Development

If you have WP-CLI installed, you can quickly set up a development environment:

# Create a new WordPress installation
wp core download
wp config create --dbname=minifair_dev --dbuser=root --dbpass=password
wp core install --url=http://localhost --title=“Mini FAIR Dev” --admin_user=admin --admin_password=password --admin_email=admin@example.com
# Create a symlink to the plugin
ln -s /path/to/mini-fair-repo wp-content/plugins/mini-fair
# Activate the plugin
wp plugin activate mini-fair

4. Install Git Updater

Mini FAIR requires Git Updater for package management:

# Download and install Git Updater
wp plugin install https://github.com/afragen/git-updater/archive/refs/heads/master.zip --activate

5. Development Environment Configuration

Enable WordPress Debug Mode

Add these lines to your wp-config.php file for development:

define(WP_DEBUG, true);
define(WP_DEBUG_LOG, true);
define(WP_DEBUG_DISPLAY, false);
define(SCRIPT_DEBUG, true);

Enable WP-CLI Commands

Mini FAIR includes WP-CLI commands for PLC management. Ensure WP-CLI is installed and available in your development environment.

6. Verify Installation

  1. Check that the plugin is active:
    wp plugin list
    
  2. Verify the REST API endpoint is working:
    curl http://your-site.local/wp-json/minifair/v1/packages
    
  3. Access the Mini FAIR admin page at: http://your-site.local/wp-admin/admin.php?page=minifair

Development Workflow

Project Structure

mini-fair-repo/
├── plugin.php              # Main plugin file
├── composer.json           # PHP dependencies
├── inc/                    # Core functionality
│   ├── namespace.php       # Main bootstrap
│   ├── admin/              # Admin interface
│   ├── api/                # REST API endpoints
│   ├── git-updater/        # Git Updater integration
│   ├── keys/               # Cryptographic key management
│   └── plc/                # PLC (Public Ledger of Credentials) functionality
└── vendor/                 # Composer dependencies

Key Components

  • PLC Integration: Handles Decentralized Identifiers (DIDs) for packages
  • Git Updater Provider: Integrates with Git Updater for package management
  • REST API: Provides endpoints for package metadata (/wp-json/minifair/v1/packages/{did})
  • Admin Interface: WordPress dashboard integration for managing DIDs and packages

Making Changes

  1. PHP Code: Edit files in the inc/ directory
  2. Dependencies: Update composer.json and run composer install
  3. Testing: Use WP-CLI commands for testing PLC functionality:
    wp plc --help
    

Debugging

  • Check WordPress debug logs in wp-content/debug.log
  • Use error_log() for debugging output
  • Monitor the REST API responses for package metadata

Using Mini FAIR

Installation for End Users

Mini FAIR currently supports integration with Git Updater, with planned support for other tools such as EDD coming soon. To use Mini FAIR, install the latest version of plugin as well as a supported tool - that is, Git Updater.

Creating a DID for your package

Once youve got Mini FAIR installed, youll need to create a DID for your package if you dont already have one. Head to the Mini FAIR page in your WordPress dashboard, and click “Create New PLC DID…” This will begin the process of creating a new PLC DID for your package - a globally-unique ID identifying your package, which you can take with you even if you change repositories in the future. It will also create two cryptographic keys: a “rotation” key, used to manage the DIDs details, as well as a “verification key”, which is used to sign releases. These keys will be stored in your WordPress database - dont lose them, as you cant recover your DID if you lose your rotation key! Once your DID has been created, itll be published in the global PLC Directory if you want to double check it. You can also sync changes to the directory via the Dashboard if your sites URL changes, or (coming soon!) to rotate your keys.

Distributing your package with your DID

To start distributing your package, youll need to add your DID to your plugin or theme. For plugins, add a Plugin ID: header to your plugins PHP file:

<?php
/**
 * Plugin Name: My Example Plugin
 * Plugin ID: did:plc:abcd1234dcba
 * ...

For themes, add a Theme ID: header to your themes style.css file:

/*
Theme Name: My Example Theme
Theme ID: did:plc:abcd1234dcba
Theme URI: Https://...

Ensure your plugin or theme is set up correctly with Git Updater, and that youre using the same site as you registered your DID with. Once thats done, youre ready to go - your package should integrate automatically with the FAIR system! You can use the FAIR Plugin to install your package directly by ID, and once its been installed once, discovery aggregators will start to list it. You can double-check your packages by checking the REST API endpoint at /wp-json/minifair/v1/packages/{did} (replace {did} with your packages DID).

Contributing

We welcome contributions! Please see the TSC repository for contribution guidelines, including the code of conduct.

Development Setup for Contributors

  1. Fork the repository
  2. Follow the local installation steps above
  3. Create a feature branch: git checkout -b feature/your-feature-name
  4. Make your changes and test thoroughly
  5. Submit a pull request

Troubleshooting

Common Issues

  • Composer dependencies not loading: Ensure youve run composer install after cloning
  • Plugin not appearing: Check that the plugin directory is named correctly and placed in wp-content/plugins/
  • REST API errors: Verify WordPress permalinks are enabled and working
  • PLC command not found: Ensure WP-CLI is properly installed and the plugin is activated

Getting Help

License

Copyright 2025 contributors. Licensed under the GNU General Public License, v2 or later. Contributions are welcomed from all! See the TSC repository for contribution guidelines, including the code of conduct.