Pat Pawlowski

PHP Script converts a list of files into an installable sugar package

Discussion created by Pat Pawlowski on Aug 3, 2017
Latest reply on Aug 3, 2017 by André Lopes

I've been using this for awhile and just added the functionality to automatically create the zip file and version it. It's not much help if you have 3 files to put in your package but if you 50 then it's pretty darn useful. 


The script expects to be run two folders down in a Sugar installation. For example in packages/INC0048757/. So if you run: 

php SugarPackager.php "INC0048757 ACME, Inc. - Create a means to link Emails to Properties"

It will look for a file named file_list.txt where it expects to find a list of files such as: 


It will then copy each file including the folder structure to the local folder assuming the first folder of all the files in the file list are two folders above. Basically it's going to copy ../../<path from the the file_list.txt file> to the local folder. So it will create a custom and maybe a modules folder in the folder where you run the script. 


While it's copying the files it's compiling the $installdefs['copy'] array. When it's done it will add this and a few other things to a manifest.php template that's included in the file and then write it out to manifest.php. 


When it creates the manifest it will also look for files named with the first word in the description you passed in, INC0048757 in the example above, with a at the end. If it finds and then it will give the current manifest a version of 3 and zip the files up into 


That's about it. If your workflow is different you can obviously modify this to suite your needs. I create my packages in a "packages" folder with a separate folder for each package/project inside of it. The downside is that my packages are cryptically named but they are all unique and can be traced back to the story in or system. 


PHP Script convert a list of files into an installable sugar package · GitHub  


Have fun,