Last few weeks me and my team had to install around 10 third party Magento extensions. We have our own local setup and development workflow, but one of the key elements is MODMAN. All extensions (ours and the third party extensions) are linked in Magento by modman. With our current setup and the situation with the number of the new third party extensions we were forced to create modman files for all new extensions. We had to create manually the definitions in the modman files in order to define how the extensions files should be linked in Magento. There was no room for mistakes, but during the process we started experiencing problems, because of the human factor. From time to time we were missing to write modman definitions for some template, layout and css files.
I spotted the need that we need reliable and automated tool, which allows us to create modman files without missing any definitions. At the beginning I was thinking to write my own shell scrip, but as I didn’t want to reinvent the wheel I decided to use my professional network and to ask the Magento community (thanks to one of my first mentors Stefan Stefanov for always reminding me to search for existing concepts / tools / frameworks rather than reinventing the wheel). I asked for help in twitter. The first minute I published my tweet I got answers from Magento community members.
The result: The community purposed 3 different working solutions and there is a promise for one more that will be wrapped in PHP Storm plugin. Below I am going to write summary about the solutions. My hope is that this may help to somebody, who is dealing with the same task as me.
Suggested by @mhauri (my choice) – instructions and download from: https://github.com/mhauri/generate-modman
Shell scrip that creates a modman file with optimal number of files. The script shows help message in case you pass incorrect arguments.
It scans the folders usually used from the Magento developers to store their files:
* There is a possibility that the shell script may not handle the cases when the developer of the third party extension has decided to put files outside of the folders listed above. In this case you can type:
generate-modman --include-others name-of-custom-folder
For reference this is a snippet of file generated by generate-modman script:
# Modman file generated by 'generate-modman' (https://github.com/mhauri/generate-modman) # app/code app/code/community/Unirgy/Dropship app/code/community/Unirgy/Dropship # app/etc app/etc/modules/Unirgy_Dropship.xml app/etc/modules/Unirgy_Dropship.xml # app/locale app/locale/en_US/template/email/udropship_password.html app/locale/en_US/template/email/udropship_password.html app/locale/en_US/template/email/udropship_statement.html app/locale/en_US/template/email/udropship_statement.html app/locale/en_US/template/email/udropship_vendor.html app/locale/en_US/template/email/udropship_vendor.html app/locale/en_US/template/email/udropship_vendor_notify_lowstock.html app/locale/en_US/template/email/udropship_vendor_notify_lowstock.html app/locale/en_US/template/email/udropship_vendor_shipment_comment.html apmplate/email/udro pship_vendor_shipment_comment.html app/locale/en_US/Unirgy_Dropship.csv app/locale/en_US/Unirgy_Dropship.csv # app/design app/design/adminhtml/default/default/layout/udropship.xml app/design/adminhtml/default/default/layout/udropship.xml app/design/adminhtml/default/default/template/udropship/carriers.phtml app/design/adminhtml/default/default/template/udropship/carriers.phtml app/design/adminhtml/default/default/template/udropship/categories.phtml app/design/adminhtml/default/default/template/udropship/categories.phtml ...
Suggested by @ottonet – instructions and download from: https://gist.github.com/ottonet/2841937ac4716578673a
This is one line shell scrip that creates modman definitions. For example if the extension contains 56 files, then the modman file will contain 56 lines. Compact and quick solution. Just works! If you don’t mind that the modman file will have too many lines, then just use it!
- Create the shell script from the snippet presented on the download page. Call the shell script “makemod”
- Make the shell script executable – chmod +x makemod
- Run the shell script inside the root folder of the third party extension – ./makemod
- The modman file will be generate in the root folder of the extension
Suggested by @fschmengler (package2modman) – instructions and download from: https://gist.github.com/schmengler/88fa071822a95224373f
This script reads the Magento Connect 2.0 package.xml and creates the modman directives based on file paths described in package.xml. The shell script just works, but of course before you run the script you must have the file package.xml in the root folder of the third party extension. To summarise the extension creates a modman file of directly downloaded Magento Connect 2.0 packages.
As you will see at the script download page, the shell script must access “app/Mage.php”, so make sure that you modify the line require_once(__DIR__ . “/../www/app/Mage.php”); in order to make the extension works for your development environment.
php package2modman.php path/to/package.xml > path/to/modman
PHP Storm plugin (work in progress) by @SimonSprankel
In twitter discussion @SimonSprankel mentioned that he is working on PHP Storm plugin for automated modman files generation. As the work is in progress I am excited to see the plugin in the near future and to use it on my projects.
Your thoughts / questions?