6.6.2. Creating and Maintaining 3rd party packages

6.6.2.1. Setting up your processor project

6.6.2.1.1. Project

Your new project should be in its own repository, e.g.

https://gitlab.com/apiopenstudio/example-processor

6.6.2.1.1.1. Directory structure

The basic requirements are a composer.json file in the extension directory root, and your code in a src directory

├── my_project
    └── composer.json
    └── src
        └── ...
    ...

6.6.2.1.1.2. composer.json

{
    "name": "<namespace>/<project_name>",
    "description": "Project description",
    "type": "library",
    "autoload": {
        "psr-4": {
            "NameSpace\\": "src/"
        }
    }
}

Minimum requirements are:

  • name - this is the namespace and project name of your extension. For example:
    • "name": "my_extension/my_processor" will be installed in vendor/my_extension/my_processor.
  • description - the description of your plugin.
  • type - library would be the usual type, but can be any of the following:
    • library
    • project
    • metapackage
    • composer-plugin
  • autoload - this tells the PHP autoloader where to look for your files. The namespacing reference tells composer to search in the src/ directory.

6.6.2.1.1.3. The src directory

This directory will contain your source class/es, e.g.

src/MyProcessor.php

6.6.2.1.1.4. Configuration ($details['machineName'])

The main difference between core processors and 3rd party, is the machineName (in the $details attribute).

By default, core will translate the machineName to the class namespace. However, this is not possible with 3rd party extensions, where the namespace is unknown.

Therefore, to help users know how to call your extension in their resources, please give the machineName the full namespace & class, e.g.

protected array $details = [
    ...
    'machineName' => 'MyProject\\MyProcessor',
    ...
];