The Basics

This section will go over the basic behavior of addons in general.

Addon Locations

This section will go over where addons can be loaded from and the difference between core and application addons.

Core Addons

All addons listed in the composer.json file will be installed by composer in the /core directory similar to the /vendor directory.

**Heads Up!** Only addons required by the root **composer.json** file will resolve dependencies required by the addon's **composer.json** file.
Application Addons

All non-core addons are considered application addons and are located in the /addons directory.

**Note:** Application addons should be committed to the project's repository.

Application addons are split into private addons and shared addons.

Private Addons

Private addons are located within /addons/{APP_REF} directory and are organized by vendor just like the /core and /vendor directories.

Private addons are only available to the application designated by the {APP_REF} directory in which they reside.

Shared Addons

Shared addons are located within /addons/shared directory and are organized by vendor just like the /core and /vendor directories.

Shared addons are available to all applications within the PyroCMS installation.

Packaged Addons

Addons can include their own addons. While it is not common the Grid and Repeater field types are good examples of an addon that come packaged with it's own dependent addons.

Addons can be registered anywhere but when using this technique they are usually found within the /addons directory within the addon itself.

Addon Object

All addon types extend the base Anomaly\Streams\Platform\Addon\Addon class and inherit some basic functionality.

Addon::isCore()

The isCore method returns whether the addon is core or not.

Returns: bool
Example
if ($addon->isCore()) {
	echo 'Yep!';
}
Twig
{% is addon.isCore() %}
	Yep!
{% endif %}
Addon::isShared()

The isShared method returns if the addon is shared or not.

Returns: bool
Example
if ($addon->isShared()) {
	echo 'Yep!';
}
Twig
{% addon.isShared() %}
	Yep!
{% endif %}
Addon::getName()

The getName method returns the translatable name of the addon.

Returns: string
Example
echo trans($addon->getName());
Twig
{{ trans(addon.getName()) }}
Addon::getTitle()

The getTitle method returns the title which generally similar to the name but does not include the addon type.

Returns: string
Example
echo trans($addon->getTitle());
Twig
{{ trans(addon.getTitle()) }}
Addon::getDescription()

The getDescription method returns the addon description.

Returns: string
Example
echo trans($addon->getDescription());
Twig
{{ trans(addon.getDescription()) }}
Addon::getNamespace()

The getNamespace method returns the addon's dot namespace with an optional key.

This is helpful for creating config keys, language keys, hinted view paths, and anything else prefixed by the addon's dot namespace.

Returns: string
Arguments
Key Required Type Default Description

$key

false

string

none

The key to append to the namespace.

Example
$addon->getNamespace(); // anomaly.module.pages
$addon->getNamespace('config.limit') // anomaly.module.pages::config.limit
Twig
{{ addon.getNamespace() }} // anomaly.module.pages
{{ addon.getNamespace('config.limit') }} // anomaly.module.pages::config.limit

{{ config(addon.getNamespace('config.limit'), 100) }}

Addon::getPath()

The getPath method returns the addon's installed path.

Returns: string
Example
require_once $addon->getPath() . '/some/old-timer/file.php'
Addon::getAppPath()

The getAppPath returns the relative application path of the addon.

Returns: string
Example
require_once base_path($addon->getPath() . '/some/old-timer/file.php');
Addon::getType()

The getType returns the addon type in singular form.

Returns: string
Example
if ($addon->getType() == 'field_type') {
	echo "I'm a field type!";
}
Twig
{% if addon.getType() == "field_type" %}
	I'm a field type!
{% endif %}
Addon::getSlug()

The getSlug method returns the slug of the addon.

Returns: string
Example
echo $addon->getSlug(); // pages
Twig
{{ addon.getSlug() }} // pages
Addon::getVendor()

The getVendor method returns the vendor string of the addon.

Returns: string
Example
echo $addon->getVendor(); // anomaly
Twig
{{ addon.getVendor() }} // anomaly