Building magento modules

magento, module, php

Solution

You'll want to develop out of local. The community folder is/was intended to be the place where you'd put modules that you downloaded or bought from the Magento Marketplace. It's my understanding that the use of this folder is being phased out, and it's Varian's recommendation that all modules be placed in the local folder, even those downloaded from the marketplace.

From a system point of view, the only difference is the community folder is searched after the core folder, but before the local folder. Checkout this path setup in app/Mage.php

$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';

$app_path = implode(PS, $paths);

set_include_path($app_path . PS . Mage::registry('original_include_path'));

So, if you have two files

app/code/community/Companyname/Models/Foo.php
app/code/local/Companyname/Models/Foo.php

Magento will use the one in the community folder first.

Problem

I'm just about to start building my first magento module but I can't find any literature on the difference between the local and community folder in core. I've noticed that some people build their modules in local and others in community, what is the difference and why should I use one or the other? Thanks

Original source