Plugins Development


With TRAX LRS, you can easily develop and add new features, like a custom API. All you have to do is to develop a Laravel package and add it to your project.

Plugin example

Let's say we want to develop a new API with a single endpoint that returns the number of statements recorded in the LRS. We need a folder (let's say ./dev/sample-plugin but you are free) with 3 files at its root.


The service provider simply loads the routes file.


namespace Trax\Plugin\Sample;

use Illuminate\Support\ServiceProvider;

class SamplePluginServiceProvider extends ServiceProvider
    public function boot(): void


The routes file declares the only route of our API and implement the matching function.


use Illuminate\Support\Facades\Route;

Route::get('sample-plugin/statements/count', function () {
    return app(\Trax\XapiStore\Stores\Statements\StatementRepository::class)->count();


The composer file describes our package.

    "name": "trax-project/trax2-plugin-sample",
    "description": "A simple example of TRAX LRS plugin",
    "require": {},
    "autoload": {
        "psr-4": {
            "Trax\Plugin\Sample\": "."
    "extra": {
        "laravel": {
            "providers": [

Local development

During development, our plugin is located in a TRAX LRS subfolder, for example ./dev/sample-plugin. But until now, it is not detected by TRAX LRS.

We need first to declare a local repository in the main composer.json file, located at the root of the TRAX LRS folder.

"repositories": [
        "type": "path",
        "url": "dev/sample-plugin",
        "options": {
            "symlink": true

Then, we use Composer to install our package from our local repository:

composer require trax-project/trax2-plugin-sample

That's it! The plugin should be detected and you can test your API.

Share your plugin

If you are proud of your plugin and if you want to share it with the community, you can push it to a public Github repository and then publish it with Packagist.

Then, your package can be added to any TRAX LRS project with:

composer require my-organization/my-plugin-name

Private deployment

Let's say your package has been pushed on a private Github repository. You can use the following commands to add your plugin to any TRAX LRS project.

composer config repositories.repo-name vcs
composer require my-organization/my-plugin-name