Skip to content

Quickstart

Alexander Saal edited this page Aug 7, 2025 · 3 revisions

Quickstart

This guide will walk you through the basic steps to get a custom application up and running using the PHP SDK. You'll learn how to install the SDK, set up the required directory structure, and create a simple example application that runs within your JobRouter® environment.

No complex setup — just the essentials to get started quickly.

Requirements

Before you begin, make sure your environment meets the following requirements:

  • Composer (Dependency Manager for PHP) is installed on the JobRouter® server
  • RDP access to the web server where JobRouter® is installed
  • Write access to the directory where the custom applications are hosted, by default this is [jobrouter]/custom_applications.
  • Basic familiarity with PHP syntax and concepts like closures and dependency injection

Step-by-step instructions

Step 1: Install the SDK

Use Composer to install the SDK into the directory that JobRouter® uses for custom applications. This directory is configurable, but by default it is located at

[path-to-jobrouter-installation]/custom_applications

To install the SDK, run the following command inside this directory:

composer require jobrouter/sdk

The package can be found in the official JobRouter GitHub Repository.

After installation, you should see a vendor/ folder and a composer.json and composer.lock file inside the custom_applications/ directory.

Step 2: Create Your First Application

Inside the custom_applications/ directory, create a new folder for your custom application. The folder name will later be used as part of the URL to access the app.

For example: custom_applications/example-app/

JobRouter configuration example of custom application

In this new folder, create an index.php file. This file is the entry point of your application and must return a PHP closure following the SDK's expected format.

Here’s a minimal example:

<?php

use Doctrine\DBAL\Exception;
use JobRouter\Common\Database\ResultInterface;
use JobRouter\Sdk\ConnectionManagerInterface;
use JobRouter\Sdk\UserManagerInterface;

return function (UserManagerInterface $userInterface, ConnectionManagerInterface $connectionManager): void {
    echo '<h1 style="color: #fc0">JobRouter SDK user interface example!</h1>';

    $userName = 'example-user';

    try {        
        $userByName = $userInterface->getUserByUsername($userName);
        echo '<h3 style="color: #f44;">User Fullname from Interface: ' . $userByName->getFullName() . '</h3>';
    } catch (\NoInstanceFoundException) {
        echo '<h3 style="color: #f44;">The user ' . $userName . ' does not exist!</h3>';
    }

    $jobDB = $connectionManager->getJobDB();
    $result = $jobDB->query('SELECT lastname, prename FROM JRUSERS WHERE username = ' . $jobDB->quote($userName));

    if ($result === false) {
        echo '<h3 style="color: #f44;">ERROR!</h3>';
        echo '<p style="color: #f44;">Message: ' . $jobDB->getErrorMessage() . '</p>';
    } else {
        if ($userFromDB = $jobDB->fetchRow($result)) {
            echo '<h3 style="color: #f44;">User Fullname from Interface: ' . $userFromDB['prename'] . ' ' . $userFromDB['lastname'] . '</h3>';
        } else {
            echo '<h3 style="color: #f44;">The user ' . $userName . ' does not exist in database!</h3>';
        }
    }    
};

Copy & paste this example into your index.php and save.

Step 3: Access Your Application

Once your application is in place, you can access it through your browser at:

http(s)://[jobrouter]/custom-applications/example-app/index.php

You should see the following result:

$\textsf{\color{#fc0}{JobRouter SDK user interface example!}}$

$\textsf{\color{#f44}{The user example-user does not exist!}}$

$\textsf{\color{#f44}{The user example-user does not exist in database!}}$

Now change the variable $userName in your script to an existing user and execute the script again.

If you have any issues, please see the Troubleshooting section, if not Congratulations! You just created your first custom application.

Clone this wiki locally