Making Extensions

I created my own Extensions (v2022) and put it into C:\Users<user>\AppData\Roaming\PHPMaker2022\extensions folder.Unfortunately, it does not show up from Tools → Extensions.I read from the documentation, Publishing Extensions as follows:If your extensions are for your own use only, you can simply put your extensions under the extensions folder, e.g. C:\Users<user>\AppData\Roaming\PHPMaker\extensions.Did I miss something?

After downloading and installing the latest version, now the extension is shown up, and can be enabled from Tools → Extensions.

However, when I was trying to re-generate ALL the script files, there was a warning message box appear from PHPMaker application:


Missing package for extension
------------------------------------------------------
The extension is disabled due to missing package

{TheExtensionName}

After closing the warning message box, then I checked the extension is back to disabled (no checked mark) from Tools → Extensions.

PHPMaker 2022 extensions are now npm packages. Make sure that your new extension have the file “package.json” in your extension folder in additional to the .xml file.Read Making Extensions.

Here is my extension folder/files:

C:\Users\<user>\AppData\Roaming\PHPMaker2022\extensions\masinoheaderfooter18 (directory)
C:\Users\<user>\AppData\Roaming\PHPMaker2022\extensions\masinoheaderfooter18\masinoheaderfooter18.xml (file)
C:\Users\<user>\AppData\Roaming\PHPMaker2022\extensions\masinoheaderfooter18\package.json (file)
C:\Users\<user>\AppData\Roaming\PHPMaker2022\extensions\masinoheaderfooter18\index.js (file)

This is the content of masinoheaderfooter18.xml file:

<?xml version="1.0"?>
<ew-extension name="MasinoHeaderFooter18" type="Header and Footer" author="Masino Sinaga">
<project>
    <attribute name="FontFamily" option="comfortaa,exo,montserrat,muli,opensans,poppins,quicksand,roboto,ubuntu" default="opensans" />
</project>
<!-- copy adminlte3 folder -->
<control id="adminlte3_copy" type="copy" action="add" ofolder="adminlte3" ifolder="adminlte3" remark="Copy adminlte3 customization folder" />
</ew-extension>

This is the content of index.js file:

global.myFontFamily = "opensans";

const ext = EXTENSIONS["MasinoHeaderFooter18"]; // Get extension object by package name
if (ext?.Enabled) { // If extension enabled
    myFontFamily = ext.Project?.FontFamily; // Get project level property value by attribute name   
}

Here is my content of package.json file:

{
  "name": "MasinoHeaderFooter18",
  "version": "18.2.0",
  "description": "Customizing Header and Footer",
  "author": "Masino Sinaga",
  "license": "SEE LICENSE IN LICENSE.md",
  "phpmaker": "extension",
  "peerDependencies": {
    "@phpmaker/core": "~18.2.0",
    "@phpmaker/php2022": "~18.2.0"
  },
  "engines": {
    "node": ">=16"
  }
}

There was a warning message: The extension is disabled due to missing package when I was trying to re-generate ALL the script files again.

Please download again: https://phpmaker.dev/download.php.

After downloading and installing the latest version, now it works properly. Thank you.

After playing with the new feature in v2022 regarding the Extensions, I think making Extensions in this version is pretty easier and faster than before. No need to zip the files anymore. Thanks again!

Please, do you have any tutorial for creating a real simple extension? I am trying to create one to add a text in all page’s footer but I do not what I am doing wrong.
Can you help?

There is no specific tutorial for Making Extensions. However, you may follow this documentation for your references.In addition, you may see the built-in Extensions that shipped with PHPMaker itself. You may refer to the existing ones if you want to create your own Extensions.