Module Loadable Package (MLP) Refactor
If you are looking to make your Module Loadable Package compatible with different versions of PHP, this guide is for you.
You will install an MLP zip file into Sugar's instance where Rector is and git has been initialized, by doing that, Sugar will add the MLP in the filesystem and git will let us know what has changed.
Prerequisites:
- Basic Setup
- A module loadable package (zip file)
Upload and Install your MLP
Upload and install your MLP as you normally would through Sugar's UI or API. Sugar will copy your files per manifest definition and perform the database operations as well (which are irrelevant for Rector).
After it has been installed, execute git status
commands to see which files were updated/added by Sugar:
sh-3.2$ git status On branch main Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: config_override.php modified: custom/application/Ext/Include/modules.ext.php Untracked files: (use "git add <file>..." to include in what will be committed) custom/Extension/application/Ext/Include/xxxx.php custom/Extension/application/Ext/Include/orderMapping.php custom/modules/ActivityStream/ custom/modules/Forecasts/Ext/clients/ custom/modules/pmse_Project/ no changes added to commit (use "git add" and/or "git commit -a")
Prepare your Rector config
Copy the paths, and paste them into the rector.php config file that was generated in the previous step, replacing the default paths in $rectorConfig->paths([
array like this (you can ignore some of the files, like *ext.php
and *orderMapping.php
):
$rectorConfig->paths([ __DIR__ . '/custom/Extension/application/Ext/Include/BuildingBlock_HelloWorldDashlet.php', __DIR__ . '/custom/clients/', __DIR__ . '/custom/modules/ActivityStream/', __DIR__ . '/custom/modules/Forecasts/Ext/clients/', __DIR__ . '/custom/modules/pmse_Project/', ]);