This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
uscaffold [2010/12/20 19:11] unirgy [FAQ] |
uscaffold [2011/10/19 19:12] (current) unirgy |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== uScaffold ====== | ||
+ | |||
+ | ===== What is it? ===== | ||
+ | |||
+ | uScaffold is a simple Magento extension that was created for personal use to assist with rapid prototyping of custom Magento extensions. | ||
+ | |||
+ | It will attempt to generate a standard Magento configuration based on simple hints from custom extension declaration XML file. | ||
+ | |||
+ | This extension is geared towards developers, who are learning Magento or just wish to speed up their extension development. | ||
+ | |||
+ | ===== How do I get it? ===== | ||
+ | |||
+ | Download the archive from this link and unpack into Magento root folder: | ||
+ | http:// | ||
+ | |||
+ | Disable or refresh cache as needed. | ||
+ | |||
+ | ===== How does it work? (by example) ===== | ||
+ | |||
+ | ==== Initialize extension with uScaffold support ==== | ||
+ | After installation of the extension, create a new file as you would normally do for a custom extension: | ||
+ | <file xml app/ | ||
+ | <?xml version=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | After you save, uScaffold will generate basic configuration for the module, which encompasses models, helpers and blocks. | ||
+ | Now you can just create PHP files as you usually would do for magento, without worrying about the configuration for them. | ||
+ | Take note: You DO NOT need to create '' | ||
+ | |||
+ | <file php app/ | ||
+ | <?php | ||
+ | |||
+ | class Custom_Extension_Model_Test extends Varien_Object | ||
+ | { | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The models, helpers and blocks are referenced by the '' | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | $model = Mage:: | ||
+ | $helper = Mage:: | ||
+ | </ | ||
+ | <code xml> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <block type=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | If you do not have any special logic for helper, you do not need to create Helper/ | ||
+ | |||
+ | ==== Working with DB tables ==== | ||
+ | |||
+ | Your module needs DB tables support? | ||
+ | No problem. | ||
+ | |||
+ | <file xml app/ | ||
+ | <?xml version=" | ||
+ | ... | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <test2 table=" | ||
+ | </ | ||
+ | </ | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | All the configuration for setup, read and write connections are made automatically, | ||
+ | If '' | ||
+ | |||
+ | ==== Event observers ==== | ||
+ | |||
+ | <file xml app/ | ||
+ | ... | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Doing the above will generate configuration to trigger an observer from your PHP model. All you have to do is to add this file: | ||
+ | |||
+ | <file php app/ | ||
+ | <?php | ||
+ | class Custom_Extension_Model_Observer | ||
+ | { | ||
+ | public function customer_load_after($observer) | ||
+ | { | ||
+ | //... | ||
+ | } | ||
+ | | ||
+ | public function sales_order_save_before($observer) | ||
+ | { | ||
+ | //... | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Frontend development ==== | ||
+ | |||
+ | <file xml app/ | ||
+ | ... | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | BAM! layout updates are loaded from '' | ||
+ | |||
+ | Do you need to run controllers for your module? | ||
+ | |||
+ | <file xml app/ | ||
+ | ... | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Frontend only events? | ||
+ | |||
+ | <file xml app/ | ||
+ | ... | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | NOTE: frontend specific observer method should start with '' | ||
+ | <code php> | ||
+ | public function FRONTEND_customer_load_after($observer) | ||
+ | { | ||
+ | //... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Admin development ==== | ||
+ | |||
+ | Similar to frontend: | ||
+ | |||
+ | <file xml app/ | ||
+ | ... | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | NOTE: admin specific observer method should start with '' | ||
+ | <code php> | ||
+ | public function ADMIN_customer_load_after($observer) | ||
+ | { | ||
+ | //... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | But wait, there' | ||
+ | |||
+ | <file xml app/ | ||
+ | ... | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | < | ||
+ | <nav> | ||
+ | < | ||
+ | <test title=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <test title=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | The code above will create admin menu entry and related ACL entry. | ||
+ | |||
+ | ===== Moving from scaffolding to production ===== | ||
+ | |||
+ | The uScaffold is not made for the production deployment, and as such is not recommended to be bundled with your extensions. | ||
+ | To retrieve automatically generated configuration, | ||
+ | |||
+ | <file xml app/ | ||
+ | ... | ||
+ | <!-- THIS PART IS CUSTOM FOR SCAFFOLDING --> | ||
+ | < | ||
+ | <!-- ... --> | ||
+ | </ | ||
+ | <!-- END SCAFFOLDING --> | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Refresh the page and you'll find '' | ||
+ | |||
+ | Just copy it to '' | ||
+ | |||
+ | ===== Wishlist ===== | ||
+ | |||
+ | * etc/ | ||
+ | * Automatic emulation of basic model classes (Model/*, Model/ | ||
+ | |||
+ | ===== FAQ ===== | ||
+ | |||
+ | == Why the method names for event observers are not in Zend convention? == | ||
+ | |||
+ | In my personal experience it is much easier to maintain event observers and method names when they' | ||
+ | Usually they' | ||
+ | |||
+ | == Why not to use admin routers as additional modules? == | ||
+ | |||
+ | There are still many stores that run Magento 1.3.x, where admin router modules are not available. | ||
+ | I was trying to make the scaffold as compatible as possible. | ||
+ | Most probably, in future versions it will be replaced with admin router modules or added as a configuration option. | ||
+ | |||
+ | ===== Example uScaffold configuration vs full Magento configuration ===== | ||
+ | |||
+ | ==== uScaffold configuration ==== | ||
+ | |||
+ | <file xml app/ | ||
+ | <?xml version=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | < | ||
+ | < | ||
+ | <test table=" | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | <nav> | ||
+ | < | ||
+ | <test title=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | <test title=" | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Automatically generated full Magento configuration ==== | ||
+ | |||
+ | <file xml var/ | ||
+ | <?xml version=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | <acl> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== CHANGELOG ====== | ||
+ | |||
+ | ===== 0.6.0 ===== | ||
+ | * Fixed copy/pasta mistake in declaring admin routers | ||
+ | * Fixed declaring mysql4 models | ||
+ | * Fixed typo in helpers declaration | ||
+ | * Added configuration ACL entries | ||
+ | |||
+ | ===== 0.5.0 ===== | ||
+ | * Initial release | ||