You are here: start » Tantalus' Firmwares » ServiceManager » php » Service


Service is an abstract class which encapsulates most work of normal services (which consists of Start/Stop of programs and Load/Save of configuration files).

New Services have to derive from Service and have to implement the methods loadConfig() and saveConfig(). loadConfig() will be called, when the web interface opens the service. loadConfig() must sent a JSONResult object to the browser. saveConfig() will be called, when the user clicks on the button save. All input widgets (which have an ID) are available as associative array (in $_POST).

The derived class has to set the variable $init to the absolute path of the init script. The init script have to support the parameters start, stop and status (see YourService).

Self-defined actions (e.g. Buttons) have to be registered by calling registerActionHandler($name). The class has to implement the method named $name.

The file Service.php includes ConfigFile.php and JSONResult.php.


Name Parameter Return value Description
loadConfig Loads configuration files
saveConfig Saves configuration files
registerActionHandler String $name Bool Registers a new action handler


Name Type Description
$init String Absolute path of the init script


// Include Service.php, ConfigFile.php, JSONResult.php
class Showcase extends Service {
    protected $init = '/etc/init.d/showcase';
    public function __construct() {
    public function loadConfig() {
	$cf = new ConfigFile();
	echo $cf;
    public function saveConfig() {
	$cf = new ConfigFile();
	$cf->setValue('listbox', array('First', 'Second', 'Third'));
	$cf->setSectionValue('datarealm', 'listbox', array('First entry', 'Second entry', 'Third entry'));
	$result = new JSONResult();
	echo $result;
    protected function button() {
	$result = new JSONResult();
	$result->setMessage('Button has been clicked');
	$result->setData('label', 'The button has been clicked');
	echo $result;
$service = new Showcase();


You could leave a comment if you were logged in.