Skip to main content

Modman for magento


Modman is the best way to arrange your magento code with custom modules. Keep your magento codes separate from the custom modules. It will help you to upgrade magento easily and also, upgrade you custom modules also.


First step is to install the modman in your system. Check this link for installation process. What i did was clone this in my local using git. Then set alias to the modman file path.


cd ~/Projects/magento/  
git clone git@github.com:colinmollenhour/modman.git modman  
vim ~/.bash_profile  
alias modman="~/Projects/magento/modman/modman"  


Create your custom module in a separate folder. Check this link for how to use modman to create modules. I used the below structure to create custom modules. Added the contents to the modman file according to the below struncture. Add these files to a repository, commit and push the changes.


+--code/
|  +--etc/
|  |  +--config.xml
|  +--Block/
|     |--View.php
+--design/
|  +--adminhtml/
|  |  +--layout/
|  |  |  +--my.xml
|  |  +--template/
|     |  +--view.phtml
|  +--frontend/
|  |  +--layout/
|  |  |  +--my.xml
|  |  +--template/
|     |  +--view.phtml
+--skin/
|  +--adminhtml/
|  |  +--custom.js
|  |  +--custom.css
|  +--frontend/
|  |  +--custom.js
|  |  +--custom.css
+--My_Module.xml
+--modman

Go to the folder where your magento code exists. Come one step out of the magento root directly. For me it was public_html. Init modman and checkout the module to the magento.


cd /path_to_magento/
modman init public_html
modman clone yourmodule git@github.com:username/yourmodule.git --branch develop

# list of files now
.modman
    .basedir (file with content public_html)
    yourmodule/
public_html
    index.php
    app
    ....

Make changes to your modules, commit and push the changes. Then to update the code in the magento, just do modman update.


#update with latest code from git and update to public_html
modman update yourmodule

#update all the modules
modman update-all

#clean deleted symlinks
modman clean

#update the code from .modman folder to public_html
modman deploy yourmodule
modman deploy-all

#link your local code to modman
modman link /path-to-module

The above code create a symlinks to the current project. Instead, we can directly copy the codes to the root directory. This will be required for theme integration.


#download the code to public_html instead of creating symlink
modman clone --copy yourmodule git@github.com:username/yourmodule.git --branch develop

#update the code on modification
modman update --copy --force yourmodule

References:
* https://github.com/colinmollenhour/modman
* https://github.com/colinmollenhour/modman/wiki/Tutorial
* http://fbrnc.net/blog/2014/11/how-to-install-a-magento-module
* http://fbrnc.net/blog/2014/12/magento-update
* http://www.classyllama.com/blog/multi-environment-magento-development-modman

Comments

Popular posts from this blog

Magento 2 - Create Attributes in Setup

Sometimes in our module we require to create product or category attributes automatically on module install. Also, we might require to add extra fields to quote, sales order, invoice, creditmemo tables. We will go through how to do that in magento 2. You can find the sample code in the git repo .