Your new project should be in its own repository, e.g.
The basic requirements are a composer.json
file in the extension directory root, and your code in a src
directory
Composer is used to define:
By default, Composer will install everything in directories in the vendor/
directory. However, ApiOpenStudio will need to have processors and modules installed separately to use them. So we need to instruct composer to install your package to a separate location.
Composer does not easily allow installation of packages anywhere other than the vemdor\
directory
(How do I install a package to a custom path for my framework?). There is an implementation for pre-defined package types (see Current Supported Package Types).
However, using composer-installers-extender, we can create custom package installation types. This is taken care of by ApiOpenStudio, and all you need to be aware of is the four package types, the installation location, and it's usage:
apiopenstudio-endpoint-package
includes/Security/vendor/
apiopenstudio-output-package
includes/Output/vendor/
apiopenstudio-processor-package
includes/Processor/vendor/
apiopenstudio-security-package
includes/Security/vendor/
{
"name": "<namespace>/<project_name>",
"description": "Project description",
"type": "<apiopenstudio_package_type>",
"keywords": [],
"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.src
directoryThis directory will contain your source class and install/update files, e.g.
src/MyProcessor.php
src/install.php
src/update.php
This contains the class for your processor.
This is optional and contains the install()
and uninstall()
functions. You Only need this if your processor needs additional data or configuration to be done when enabling or disabling it.
This is optional and is only required if there are data updates that need to be done between your package versions.
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',
...
];