Getting Started

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.

Only addons required by the root composer.json file will resolve dependencies required by the addon's composer.json file.{.notice}

Application Addons

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

Application addons should be committed to the project's repository.{.notice}

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.

isCore

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

if ($addon->isCore()) {
    echo 'Yep!';
}
{% is addon.isCore() %}
    Yep!
{% endif %}

isShared

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

if ($addon->isShared()) {
    echo 'Yep!';
}
{% addon.isShared() %}
    Yep!
{% endif %}

getName

The getName method returns the translatable name of the addon.

echo trans($addon->getName());
{{ trans(addon.getName()) }}

getTitle

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

echo trans($addon->getTitle());
{{ trans(addon.getTitle()) }}

getDescription

The getDescription method returns the addon description.

echo trans($addon->getDescription());
{{ trans(addon.getDescription()) }}

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.

An optional key can be provided to create a dot-namespace config key for example.

echo $addon->getNamespace();
// anomaly.module.pages

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

{{ addon.getNamespace('config.limit') }}
// anomaly.module.pages::config.limit

You can see how this could be used to generate a config dot-namespace key.

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

getPath

The getPath method returns the addon's installed path.

require_once $addon->getPath() . '/some/old-timer/file.php';

getAppPath

The getAppPath returns the relative application path of the addon.

require_once base_path($addon->getAppPath() . '/some/old-timer/file.php');

getType

The getType returns the addon type in singular form.

if ($addon->getType() == 'field_type') {
    echo "I'm a field type!";
}
{% if addon.getType() == "field_type" %}
    I'm a field type!
{% endif %}

getSlug

The getSlug method returns the slug of the addon.

echo $addon->getSlug();
// pages
{{ addon.getSlug() }}
// pages

getVendor

The getVendor method returns the vendor string of the addon.

echo $addon->getVendor();
// anomaly
{{ addon.getVendor() }}
// anomaly