Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should use <code>community</code>, if your module is planned to be distributed to the public, to allow other Magento developers to use your module in their own Magento projects, too.</p> <p>That's what Varien calls a <a href="http://www.magentocommerce.com/magento-connect" rel="nofollow">Magento Extension</a>.</p> <p>You should use <code>local</code> instead, if you do not want to distribute to the public, but are developing the module mainly for a specific shop (or maybe your personal use) only.</p> <p>To better understand the difference between the <code>local</code> and the <code>community</code> folder, it helps to know how the Magento Autoloader works:</p> <p>When a <code>class</code> is about to be instantiated in Magento, the Autoloader will search for matching classes in the order given by PHPs <a href="http://www.php.net/manual/en/function.set-include-path.php" rel="nofollow"><code>include_path</code></a>.</p> <p>Magento initially sets its <code>include_path</code> in <code>app/Mage.php</code> upon start:</p> <pre><code>: define('DS', DIRECTORY_SEPARATOR); define('PS', PATH_SEPARATOR); define('BP', dirname(dirname(__FILE__))); Mage::register('original_include_path', get_include_path()); : $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')); : </code></pre> <p>The Magento Autoloader searches paths in the <strong>same</strong> order they appear in <code>include_path</code>:</p> <pre><code>1st /app/code/local/ 2nd /app/code/community/ 3rd /app/code/core/ 4th /lib/ : </code></pre> <p>Assuming you are trying to instantiate a class named <code>Namespace_Module_Block_Hello</code> for example, that would result in having Magentos Autoloader searching the paths given by <code>include_path</code> for a file named <code>Namespace/Module/Block/Hello.php</code>*: </p> <pre><code>1st /app/code/local/Namespace/Module/Block/Hello.php 2nd /app/code/community/Namespace/Module/Block/Hello.php 3rd /app/code/core/Namespace/Module/Block/Hello.php 4th /lib/Namespace/Module/Block/Hello.php : </code></pre> <p>The <strong>first</strong> file found will win, i.e. get instantiated. So if the same file exists in <code>local</code> AND <code>community</code> for example, the <code>local</code> one would be instantiated. </p> <p>This allows developers to freely extend/override/overload/ignore classes.</p> <hr> <p>*<sub>see <code>lib/Varien/Autoload.php::autoload()</code> for name conversion rules</sub> </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload