|
| 1 | +<!-- |
| 2 | + This source file is part of the open source project |
| 3 | + ExpressionEngine User Guide (https://github.com/ExpressionEngine/ExpressionEngine-User-Guide) |
| 4 | +
|
| 5 | + @link https://expressionengine.com/ |
| 6 | + @copyright Copyright (c) 2003-2023, Packet Tide, LLC (https://packettide.com) |
| 7 | + @license https://expressionengine.com/license Licensed under Apache License, Version 2.0 |
| 8 | +--> |
| 9 | + |
| 10 | +# Modernizing Existing Add-ons |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +The ExpressionEngine 7.2 release brought a new add-on development approach, which generates the majority of the add-on's needed files and structure. It also brings additional organization to how add-ons are developed. |
| 15 | + |
| 16 | +NOTE: These changes do NOT break existing add-ons. The old development methodologies will still work. However once these changes are made the add-on will require ExpressionEngine 7.2+. |
| 17 | + |
| 18 | + |
| 19 | +The idea of an add-on _being_ a "plugin", "module", "extension", "fieldtype", etc. is no longer accurate. Instead, an add-on can include features such as template tags, actions, fieldtypes, or extensions. |
| 20 | + |
| 21 | +To utilize the updated method for creating add-ons, you will need to make some small changes to your current add-ons. However, this does not mean that you need to completely convert your add-ons to the new method. After making these updates, you can continue using your existing add-ons and begin creating new ones using the updated method. |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +[TOC] |
| 26 | + |
| 27 | +## Updating your mod.addon.php file |
| 28 | +In order to use the new approach, you will have to have your mod file use and extend the module add-on service. Your mod file will also need to add the protected variable $addon_name in the class |
| 29 | + |
| 30 | + |
| 31 | +``` |
| 32 | +use ExpressionEngine\Service\Addon\Module; |
| 33 | +
|
| 34 | +class Amazing_add_on extends Module |
| 35 | +{ |
| 36 | + protected $addon_name = 'amazing_add_on'; |
| 37 | +
|
| 38 | +``` |
| 39 | + |
| 40 | + |
| 41 | +## Updating your mcp.addon.php file |
| 42 | + |
| 43 | +In order to use the new approach, you will have to have your mcp file use and extend the Mcp add-on service. Your mcp file will also need to add the protected variable $addon_name in the class |
| 44 | + |
| 45 | +``` |
| 46 | +use ExpressionEngine\Service\Addon\Mcp; |
| 47 | +
|
| 48 | +class Amazing_add_on_mcp extends Mcp |
| 49 | +{ |
| 50 | + protected $addon_name = 'amazing_add_on'; |
| 51 | +``` |
| 52 | + |
| 53 | +## Updating your ext.addon.php file |
| 54 | + |
| 55 | +In order to use the new approach, you will have to have your ext file use and extend the Extension add-on service. Your ext file will also need to add the protected variable $addon_name in the class |
| 56 | + |
| 57 | +``` |
| 58 | +use ExpressionEngine\Service\Addon\Extension; |
| 59 | +
|
| 60 | +class Amazing_add_on_ext extends Extension |
| 61 | +{ |
| 62 | + protected $addon_name = 'amazing_add_on'; |
| 63 | +``` |
| 64 | + |
| 65 | +## Updating your upd.addon.php file |
| 66 | + |
| 67 | +In order to use the new approach, you will have to have your upd file use and extend the Installer add-on service |
| 68 | + |
| 69 | +``` |
| 70 | +use ExpressionEngine\Service\Addon\Installer; |
| 71 | +
|
| 72 | +class Amazing_add_on_upd extends Installer |
| 73 | +{ |
| 74 | +``` |
| 75 | +## A Note on Plugins |
| 76 | +If your add-on is currently a plugin and you are looking to take advantage of the new add-on development methodologies, we recommend migrating your plugin methods (functions) to your mod file first. This can be done with a simple copy and paste. |
0 commit comments