A new section is open: Downloads

Over two months have passed since my last post, and I realize that the backlog of the things I wanted to write about is growing every day. However, I’m stubborn and I won’t get discouraged, especially now that I learned how to stop making goals, and I switched to projects. Much better feeling, stronger sense of accomplishment, definitely a better way of planning. If you’re a supporter of the idea the one should set goals, you definitely have to try working on projects instead. I promise you won’t go back to goals, ever. This is a topic for my other blog, though, and I might discuss it there.

Back to the original topic

As written in the subject, I can finally open the Downloads section, and I’m doing it by publishing a script that will hopefully save a good amount of work and some serious headache to all Developers who, like me, start working with the powerful, yet very complicated, Magento E-commerce framework.I started working on Magento a few months ago, and I immediately crashed, head first, against it. Let’s say that the first impact got me quite frustrated, as one can deduct by reading some of my questions about it on StackOverflow. I’m used to lean and simple frameworks, that adopt a fairly simple approach for managing their plugins, and Magento is not one of them. Its targets are extreme flexibility and extensibility, but this comes with a serious drawback: its design is quite “academic” and it requires developers to follow strict rules in terms of naming convention, file location, file structure and configuration file. This contribute to robustness, but it doesn’t make it easy to get started, especially for people like me, who:

  • Have never seen the framework before.
  • Lack formal training on it.
  • Are getting older. I’m only 36 (as of 2012), but I have difficulties remembering the structure of a directory tree, including the capitalization of each file and subdirectory.

In addition to the above, my age comes with another strong attribute: laziness. I don’t like to do things twice, and, often, I don’t like to do them even once. Even worse if they are tedious like creating folders and files manually, and having to memorize their capitalization. No way.

Let’s put our Servants to a good use

That’s not a typo. A servant is someone who performs duties for others. In our case, we have so many servants ready to do anything we can think of: our computers. They are incredibly stupid, yet amazingly fast. Tell them to write something a million times, they’ll do it without a complaint. Unlike me.

Considering the above, it made perfectly sense to me to write a script that allowed them to shine and make me happy. A couple of hours of work, and the first version of Extension creator script for Magento was ready!

Here’s a list of the features so far:

  • It creates the whole extension folder, including app/Code, app/Design, app/Etc and all its sub-folders.
  • It automatically creates a basic config.xml in app/Code/etc.
  • It automatically creates a basic Helper in app/Code/Helper.
  • It automatically creates the Module configuration file in app/etc/modules.
  • It can create Symbolic Links, pointing to the Extension folder, in a Magento installation directory. This is one of the most useful features, as it allows to keep Extension files physically separated from the runtime environment, while still making Magento think that they have been installed locally.

That doesn’t seem much, but you should try using it first, and you’ll see it can save you hours of work. Personally, I lost track of the hours I spent debugging an almost blank extension that didn’t work because of some uppercase/lowercase file.

Added bonus of Symlinks: easier Source Control!

Since Magento requires that module files are scattered inside several of its folders, using Source Control tools becomes a nightmare. If files are copied in the required locations, one has to checkout a folder here, another folder there, a file here, a file there, some more files here and there. Of course, commits require the same amount of work.

By using Symlinks to point to the files and folders, they can be kept all together in the same place. The Extension’s folder structure will mimic Magento’s one, but its physical location will be completely independent. This way, a commit on the Extension root folder is all that will be needed to commit changes to the repository. One commit to save them all!

Usage

Using the script is extremely easy. In its simplest version, it runs taking just three parameters. Here’s an example:

CreateMagentoExtension -Namespace MyNamespace -ExtensionName MyExtension -DestinationDir C:\MagentoDev\MyExtensions

This will create a folder called MyNamespace_MyExtension in C:\MagentoDev\MyExtensions, and fill it with the directory tree required by Magento Extensions. The Extension’s configuration file will already contain all the sections needed for it to run properly inside Magento. All you’ll have to do is implementing a Block and/or a Controller and you’ll be good to go!

 Note

The script requires Powershell 2, therefore it’s not of much use if you run Linux. I’m going to release a Bash version of the script soon, so stay tuned!

Download links

2 replies
  1. Bernie says:

    Hello there! I know this is kinda off topic but I was wondering if you knew where I could get a captcha plugin for my comment
    form? I’m using the same blog platform as yours and I’m having difficulty finding one?
    Thanks a lot!

    Reply
    • diego says:

      I use wp-reCAPTCHA, which has an option that allows to activate it for comments. It does everythig by itself, I just needed to tick a checkbox. 🙂

      Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.