To start, Magento was created using the Zend framework. Therefore, the naming conventions will pretty much follow the rules established by Zend. A quick review of the naming conventions in the Zend framework is as follows:

  • All framework classes are stored under a root directory
  • Class names may only contain alphanumeric characters
  • Numbers are allowed in class names, but discouraged
  • Underscores are allowed, however, they are only permitted in place of a path separator
  • If the class name has more than one word, each word’s first letter must be capitalized
  • Code that is not a part of the standard or extras libraries, but, is being deployed next to the Zend Framework must never start with Zend_ or ZendX_
  • Abstract classes are the same as the other classes, but, they must end in _Abstract
  • Interfaces follow the same rules as other classes, but, it’s encouraged but not required to end the name with _Interface

Now that we have some general rules, let’s take a look at the autoloader located in app/Mage.php:

/**
* Set 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';

$appPath = implode(PS, $paths);
set_include_path($appPath . PS . Mage::registry('original_include_path'));
include_once "Mage/Core/functions.php";
include_once "Varien/Autoload.php";

…You’ll notice that the first four lines show the Magento loading hierarchy that we’re always talking about.

Above, when talking about the Zend naming rules, this rule is very important in the relationship with the Magento autoloader: Underscores are allowed, however, they are only permitted in place of a path separator. The naming of classes is standardized based on the location in the file system. If we take a look in the Magento core for an example, we can see how this works. I’ve chosen to take a peek at the file located here: /app/core/Mage/Authorizenet/controllers/Directpost/PaymentController.php. Here is the line we’re worried about:

class Mage_Authorizenet_Directpost_PaymentController extends Mage_Core_Controller_Front_Action

Let’s go through the rules:

  • It’s stored under a root directory
  • It’s alphanumeric
  • No numbers
  • Underscores… it’s right, because, it’s located in the Mage/Aurthorizenet/Directpost/ directory, and, the file is named PaymentController.php … so, we replace the / with _ and that’s our class name.
  • It has more than one word, so, each word is capitalized.
  • It IS a part of the system, so, no worries there
  • It’s NOT an abstract class
  • It’s NOT an interface

So, since everything is named properly, the Magento autoloader will pick up the underscores, and, know the location, and, everything will run along smoothly. This madness of standardization allows the Magento autoloader to do all the dirty work of including (loading, autoloading) the classes thereby eliminating the need for us to use include_once or require_once.

 

Idenfity

This is pretty straight forward. The adminhtml area is located in app/design, and, so is the frontend area.

Explain

It it’s most basic sense, the adminhtml area stores the information about the admin panel, and, the frontend area stores the information about the web store the customer can see. Inside of each of these areas lives the hierarchical structure of Magento allowing for easy creation of a new look-and-feel, as well as the addition of any modules and other customization.

Inside of frontend

The next level of frontend is the ‘area’. In a base Magento install, there are two areas, base and default. Inside of default, there are packages (or, theme names, one could call them). The base install contains blank, default, iphone, and modern. Inside of each of these directories, you will find all of the .phtml, .xml, and other files, images, directories that make up the front end for said package.

Inside of adminhtml

Following the same logic as the fronend, Magento base install comes with a ‘default’ directory in the admin. Inside of default is another default directory. Inside of THAT default directory you’ll find layout, locale, and template directories. If you desired to change the admin look-and-feel, you would do so here following the rules of customization as outlined by Magento.

 

Magento skins are located in the skin/frontend/your_interface/your_theme/ directory. Essentially, the skin directory is just a place to keep all of your images, block-specific JavaScript, and CSS files.

For example, if you look in the skin/frontend/base/default/ directory of a fresh Magento install, you’ll see directories for css, images, js and a favicon.ico file. And, if you look in the skin/frontend/default/default/ directory, you’ll see directories for css, images and a favicon.ico file.

If you examine the source code of a default Magento install, you’ll see things like:

<link rel="stylesheet" type="text/css" href="http://www.yoursite.com/magento/skin/frontend/base/default/css/widgets.css" media="all" />
<link rel="stylesheet" type="text/css" href="http://www.yoursite.com/magento/skin/frontend/default/default/css/print.css" media="print" />

Notice the /base/default/ and /default/default/ directories? If you were to create your own custom theme, then, you would use the directory that corresponds with your theme name. Note: Remember, both the default/default and the base/default directories are overwritten in a system upgrade, so, don’t change the code there… instead, create a new theme, and, a new skin directory for your new theme.

That said, Magento uses it’s standard Fall-Back Hierarchy for the skins directory too:

  1. First, look for the file in skin/frontend/your_interface/your_theme/
  2. If the file is not found, then, look for it in skin/frontend/your_package/default/
  3. If it’s still not found, then, look for it in skin/frontend/base/default/
  4. Finally, if the file is not in the base, then, a Magento throws a rendering error
 

Layouts and templates are viewed differently by Magento. This post does not serve as a tutorial for Magento Templates and Layout Files, it simple discusses where they are located and a bit of general information. Layouts Layouts are built by using XML tags. You do NOT need to be a programmer or really have any [...]

 

A Magento module is created in the local or community codepools.  Normally, one would create the module in the local directory. The local codepool is found in app/code/local (you might have to create this directory depending on the install). The first nested directory after local becomes the module’s namespace.  Then, the second nested directory inside [...]

 

There are three codepools.  Core, Community and Local.  Modules are located in the codepools.  Magento will look for a module first in the local codepool, then in the community codepool, and finally in the core codepool.  This structure allows developers to extend the core without disrupting the core.  This is valuable because it allows easy [...]

 

Download progressupload from http://pecl.php.net/package/uploadprogress into a directory on your server using wget… as of this writing, the latest stable release is: http://pecl.php.net/get/uploadprogress-1.0.3.1.tgz  e.g. wget http://pecl.php.net/get/uploadprogress-1.0.3.1.tgz Unpack : tar -zxvf uploadprogress-1.0.3.1.tgz Change into the unpacked directory: cd uploadprogress-1.0.3.1 phpize ./configure make make install edit php.ini, add: extension=uploadprogress.so … while you’re in there, you might as well update upload_max_filesize and post_max_size [...]

© 2012 John Shipp Suffusion theme by Sayontan Sinha