PHPackages                             alpipego/resizefly-addon-template - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alpipego/resizefly-addon-template

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

alpipego/resizefly-addon-template
=================================

Use this template to create a new add-on for ResizeFly

07PHP

Since Feb 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/alpipego/resizefly-addon-template)[ Packagist](https://packagist.org/packages/alpipego/resizefly-addon-template)[ RSS](/packages/alpipego-resizefly-addon-template/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

ResizeFly Add-on Template
=========================

[](#resizefly-add-on-template)

Use this template to register add-ons for the ResizeFly plugin.

Installation
------------

[](#installation)

- Via Composer:
    Create a new project with

```
composer create-project alpipego/resizefly-addon-template:dev-master  --no-install --remove-vcs YOUR_ADDON_NAME
```

- Manually:
    Check out this repository

```
git checkout git@github.com:alpipego/resizefly-addon-template.git YOUR_ADDON_NAME
```

Make sure to update the namespace in all files and the `composer.json`.

Configuration
-------------

[](#configuration)

### WordPress Plugin Header

[](#wordpress-plugin-header)

Update the plugin header, check [https://codex.wordpress.org/File\_Header#Plugin\_File\_Header\_Example](https://codex.wordpress.org/File_Header#Plugin_File_Header_Example) for examples

### ResizeFly Add-on Config

[](#resizefly-add-on-config)

Update the `name`, `nicename`, `version` and `min_version` to correctly register your add-on in the parent plugin. Take extra care not to use the `name` of another installed add-on, as this would override it.

```
$addon = [
    'name'        => 'addon_template', // short name, only lowercase letters and underscores
    'nicename'    => 'Add-on Template', // Nice name, for use in UI
    'file'        => __FILE__, // Reference to this file, don't change
    'path'        => realpath( plugin_dir_path( __FILE__ ) ) . '/', // Path to this add-on, don't change
    'url'         => plugin_dir_url( __FILE__ ), // URL to this add-on, don't change
    'version'     => '1.0.0', // Version string, should match add-on version above
    'min_version' => '3.1.0', // Required minimum version of ResizeFly plugin, should match required version in composer.json
];
```

Your add-on is now registered with the parent plugin and has access to it's DI container, i.e. you can inject the plugins (or even other add-ons') classes into your code.

Dependency Injection Container
------------------------------

[](#dependency-injection-container)

ResizeFly uses a custom Pimple based dependency injection (DI) container. Register your classes:

```
$plugin[ $addon['name'] ] = function ( $plugin ) use ( $addon ) {
    return new Addon( $plugin['addons'][$addon['name']] );
};
```

The add-ons configuration gets passed back to the `Addon()` class.

Add-On
------

[](#add-on)

You can then use the `$config` array to e.g. register a custom script for the images:

```
