Magento first Lesson--Introduction to directory Structure

Source: Internet
Author: User

Magento First Lesson--Introduction to directory Structure A Why Magento is strong

Magento is built on the basis of the Zend Framework, which guarantees the security and stability of the code. There are many reasons to choose Zend, but the basic reason is that the Zend Framework provides an object-oriented code base and has good team support. Through this framework,Magento is mainly built around three basic points:

1. Flexibility: We believe that every solution is as unique as its business support. the Magento code can be customized seamlessly.

2. upgradeability:Magento can be easily customized without losing the ability to upgrade, because the core code and local customization capabilities are decoupled from the community.

3. Speed and safety: The code standards used by developers follow best practices, ensure the efficiency of program operation, and provide a secure online store program.

Magentothe configuration system is likeMagentothe heart, supporting theMagentothe operation. This set of configuration systems is in charge of almost all "Module (Module)/model(model)/class(Class)/template(template file)/ etc(configuration file) ". It put the wholeMagentothe system is abstracted and described with a configuration file. The "config file" Here is not a physically existing file, butMagentoA segment that is dynamically generated based on the current system stateXML. Most ofPHPdevelopers are not accustomed to such abstraction layers as it increases the complexity of programming. But such abstractions provide unparalleled flexibility, allowing you to override the default behavior of almost any system.

Two directory Structure of the Magento

Detailed description of each directory:

/app – Program root directory

/APP/ETC – Global configuration file directory

/app/code – All modules are installed with their model and controller directories

/app/code/core – Core code or Certified module, if you want to upgrade do not code here

/app/code/community – Community version of the module catalog

/app/code/local – Custom code catalog

/app/code/core/mage? – Magento Default Namespace

/app/code/core/mage?/{module} – Module root directory

/app/code/core/mage?/{module}/etc – Configuration file directory for the module

/app/code/core/mage?/{module}/controllers – Controller of the module

/app/code/core/mage?/{module}/block? – Display the logical class of the block

/app/code/core/mage?/{module}/model? – The object model of the module

/app/code/core/mage?/{module}/model/mysql4? – Module's resource model

/app/code/core/mage?/{module}/sql – Installation and upgrade of each version of the module with SQL

/app/code/core/mage?/{module}/sql/{resource}/- Upgrade is a resource model that is needed

/app/code/core/mage?/{module}/sql/{resource}/{type}-{action}-{versions}. (sql|php) – Resource upgrade files such as : Mysql4-upgrade-0.6.23-0.6.25.sql

/app/design – Design Package catalog (layouts, templates, translations)

/app/design/frontend – Front-end design

/app/design/adminhtml – Background management design

/app/design/{area}/{package}/{theme} – Customized Themes

/app/design/{area}/{package}/{theme}/layout – Defines the . xml file for the display block

/app/design/{area}/{package}/{theme}/template – . phtml (HTML with PHP tags) template

/app/design/{area}/{package}/{theme}/locale – text translation for zend_translate compatible themes

/app/locale – Localization files

/app/locale/{locale (en_US)} – text translation for zend_translate compatible modules

/skin/{area}/{package}/{theme}/-CSS and images

/lib – Common library

/js – javascripts

/media – Upload file directory

/tests – Test Catalog

/var – Temp file directory

Three Description of the config file tag

Magento Each module has the etc folder, which is the necessary folder, there is at least one config file configuration, the file configuration is correct, It plays a key role in directly giving the module the ability to operate correctly. Magento always get the class name through the configuration file, this logic looks a little complicated, but the advantage of doing so is obvious, we can Change the code without changing the Magento Magento 's core functionality. the metabase config file is always <config> as the root tag. A group of labels with various functions in the bread.

Approximate file structure:

<config>
<modules>declares the name of the folder inside the code area where the module resides;
<admin>define background-related routing (typically only involves routing);
<adminhtml>Define BackgroundLayout,Events,Translateand so on;
<frontend>define foreground-related routes,Layout,Events,Translateand so on;
<global>defines the global (including foreground and background) of the module.Block,helper,modelsuch as the designation of related classes;
</config>

Detailed Explanation:
===============================================

<modules>
< code Package folder name _ module name >
<version>0.2.0</version>
</ Code Package folder name _ module name >

</modules>

ModulesThe label is simple, just declare the name of the folder inside the code area where the module resides, such asMagefolder, if the module is in the code area of theLocal, it is declared according to a folder of your own definition,versiontag, the version number of the module. This version number directly affects theSQLthe installation file under the folder.


================================================
<admin>
<routers>
<Front End name>
<use>admin</use>
<args>
<module>Code Package name_Module Name</module>
<frontName>Front End name</frontName>
</args>
</Front End name>
</routers>
</admin>


Adminlabel groups, which define the background-related routes (typically only involve routing),FrontnameThe tag defines the module name involved in the access, which involves the routing part, which is not said here. Usetags, which are defined as permissions for use, are defined in the general background asAdmin, here the module name andFrontnamedefined with the same name


================================================
<adminhtml>

<layout>

Defining Layout

</layout>
<translate>

define a translation module

</translate>
<events>

Defining Events Observer

</events>

</adminhtml>

adminhtml Tag Group, define background layout,events,translate , etc.


================================================
<frontend>

<routers>

< front end name >

<use>standard</use>

<args>

<module> Code Package name _ module name </module>

<frontName> Front End name </frontName>

</args>

</ front name >

</routers>
<layout>

<updates>

< front end name >

<file> layout Files </file>

</ front name >

</updates>

</layout>

</frontend>

Frontend Tag Group, defines the foreground related route (usually only involves the route),thefrontname tag defines the module name which is involved in the access, this involves the route part, here does not say.
The use tag, which defines the usage permissions, is defined as standard in the background,where the module name is the same as the frontend definition.
The Layout tab specifies which layouts file the module uses.


================================================
<global>
Global label, which defines the designation of related classes such as Block,helper,model under the module , such as:


< front end name >

<class> class package under the module </class>

</ front-end name >
</ Helpers>


new module, if there is helper block model model resourcemodel tags, as rewritten modules, classes should be added <REWRITE> <CLASS> example:


<models>
< frontend name

<class>model class folder </class>
<resourceModel> Resource Name </resourceModel>

</ front name >
< resource name >

<class> Resource class folders </class>
<entities>

< entity class name ><table> table name </table></ entity class name >

</entities>

</ Resource Name >
</models>


The resource name is typically set to the front-end name _mysql4 folder, the Resource class folder is also assigned to this folder, the entity class name is the corresponding class for the table, and not all tables have entity classes.


Resources tab, which is specified only if the module needs to install the file. For example:


<resources>
< front-end name _setup>

<setup>

<module> Code Package name _ module name </module>

<class> Resource Installation class </class>

</setup>
<connection>

<use>core_setup</use>

</connection>

</ Front-end name _setup>

< front-end name _read>

<connection>

<use>core_read</use>

</connection>

</ Front-end name _read>

< front-end name _write>

<connection>

<use>core_write</use>

</connection>

</ Front-end name _write>
</resources>


The resource installation class is generally the Setup class under the MYSQL4 resource , integrated in the mage_core_model_resource_setup.

Magento first Lesson--Introduction to directory Structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.