Data scheme for the update server

SW JProjects - Documentation
Category: Components

The default data schema is Joomla CMS . Creating a custom data schema plugin for the update server.

What is a software update server?

When developing your software (if you use SW JProjects for the software catalog), you fix bugs and add new features: your application (component, plugin, module, library) begins to live its life. During the lifecycle of your application, you release new versions. In the development world, SemVer;(article Semantic versioning (semver) in Joomla and its extensions in Russian). Your previous versions, which are working for your users, need to somehow find out about the release of the new version, and then get a link to download the files and update them. To do this, an update server is raised on the developer's side, which provides the program with all the necessary information.

Video (in Russian)

Own update server for Joomla extensions

Historically, the SW JProejcts component was created as an extension catalog for Joomla. According to the official Joomla documentation (old on docs.joomla.org , new on manual.joomla.org ) to update the CMS on the part of the developer, you need to provide the URL for the information:

  • list of extensions (extensionset, optional)
  • for a specific extension (updates)
  • for the list of changes (changelogs, optional)

Upon requests to these URLs, the update server returns XML of a Joomla-specific structure. The Joomla component SW JProjects allows you to generate all the necessary data automatically and your extensions on your clients' websites will always know about the release of new versions of the plugin or module. You will find out the necessary URLs to insert into the XML manifest of your extension when creating and configuring the project.

Update server for NON-Joomla extensions

However, what should I do if you don't have a Joomla extension, but any other type of file or plugin for WordPress (or any other CMS), or a software module not for web development, but for Windows applications? Or (for example) you are a manufacturer of CNC machines and offer customers to update machine firmware periodically. In this case, you will be hampered by the Joomla-specific data structure in the update server and you will want to create your own, maybe simpler data schema. You may also need a different format than XML (JSON, SOAP, or something else). In these cases, you may find it useful to create your own data schema for the update server.

Update server data schemes

Starting with SW JProejects version 2.5.0, you can create an update server not only for Joomla extensions, but also your own. The formation of the data structure for the Joomla extension update server has been moved to a separate plugin. You can create your own plugin and implement the data structure you need in it by adding or removing the displayed data. The update server in the component still displays information about the list of projects and their versions, about a specific project and its changelog. You can select the update server data schema globally for the entire component, select a different data scheme for the project category, and select a scheme for each project. 

Creating a data scheme plugin for the update server

If you are a developer, study the Joomlaserverscheme plugin of the swjprojects plugin group, which is included in the component. This plugin generates XML update manifests according to the Joomla specification. Also study sample plugin on GitHub, which implements the same structure with minor changes, but in the JSON format.

Your plugin does not extend CMSPlugin, butJoomla\Component\SWJProjects\Administrator\Serverscheme\ServerschemePlugin ( fileadministrator/com_swjprojects/src/Serverscheme/ServerschemePlugin.php ), which inherits the CMSPlugin of the Joomla core. In it, you can view the added additional methods necessary for the data schema plugin to work.

Required class properties

The main plugin file is located in the src/Extension folder. Properties are important to you in it.:

$mimeType
The MIME data type that will be set for your data in the server header Content-Type. It can be checked on the side of the client program receiving updates.
$charset
Encoding of the transmitted data.
$name
The name of your data schema displayed in the lists in the component interface.
$type
The unique "system" name of your data schema. It is saved in the parameters of the component, categories and projects.
/**
 * @var string
 * @since 2.5.0
 */
protected string $mimeType = 'application/json';

/**
 * @var string
 * @since 2.5.0
 */
protected string $charset = 'utf-8';

/**
 * @var string
 * @since 2.5.0
 */
protected string $name = 'Custom Sample JSON';

/**
 * @var string
 * @since 2.5.0
 */
protected string $type = 'customsample';

We recommend using branded prefixes in the names of plugins (including class names), as well as the $type properties to maximize class unification. For example, not "wordpresserverscheme", but "vendorwordpresserverscheme", where "Vendor" is your brand.

renderOutput method

This is a method that creates a data structure in the format you need. For convenience, the logic of creating data structures for a list of projects (collection), a specific project (updates) and a list of project changes (changelogs) is divided into 3 methods that you implement in your plugin yourself.

public function renderOutput(array $data): mixed
{
	switch ($this->getScheme()) {
		case 'updates':
			$output = $this->buildProjectUpdatesJson($data);
			break;
		case 'changelogs':
			$output = $this->buildChangelogsJson($data);
			break;
		case 'collection':
		default:
			$output = $this->buildCollectionJson($data);
			break;
	}

	return $output;
}

In your methods, you can form the structure as you need, use or not use data from the $data array, and add your own data from a database or third-party sources.

The created data schemas are cached in the Joomla cache.

WebTolk Joomla Extensions

96 Extensions
11 Categories
474 Versions released
516061 Downloads
Cart
Cart is empty