I've recently added a package to my project via composer. That package would not work after I generated code and selected the "Composer update" checkmark. Here's a step-by-step on how to get PHPMaker 2019 to include the package during the Composer update.
From the website packagist dot org, or your package's documentation, find the composer installation command of your 3rd party package. For example:
composer require xyz/php-sdk
You will need the text after the "composer require".. in this case, "xyz/php-sdk"Also from the same website, find the latest version. ie.. v2.3.0
Next, in the PHPMaker 2019 help file, select the "Index" tab and search for "Using User Code".
From the Help file, copy the code example "2. BeginGenerate and EndGenerate Events" and change to BeginGenerate
Events.on("BeginGenerate", () => {
// Your code to do something after generation
});
- From the help file, copy the example "4. Project Settings". Paste it to the Event.on section above.
Events.on("BeginGenerate", () => {
// Your code to do something after generation
PROJ.Require = { "aws/aws-sdk-php": "3.65.1" }; // In JSON format
});
- Now substitute your package install and version information you collected above.
Events.on("BeginGenerate", () => {
// Your code to do something after generation
PROJ.Require = { "xyz/php-sdk": "2.3.0" }; // In JSON format
});
Hint.. you can add the "^" to the version to indicate this version or future versions:
Events.on("BeginGenerate", () => {
// Your code to do something after generation
PROJ.Require = { "xyz/php-sdk": "2.3.0" }; // In JSON format
});
Paste this code to the bottom of your usercode.js file located in the install directory as indicated at the top of the help file.
Generate your PHPMaker 2019 code with the "Composer update" checkmarked. It should all compile without errors.