Magento Notes – Part 2: Development tools
Posted 12 months ago at 09:45. 0 comments
It’s a not a secret that Magento is complex and has a quite steep learning curve. Part of that problem stems from the fact that there isn’t much documentation on the developer API. Without a good introductory book and reading lots of forum and blog posts, it’s a pain to get even the simplest things done. Digging deeper, a working understanding of OOP design patterns and the Zend Framework is almost necessary.
Let’s see a rough estimate what we’re facing when developing for Magento (version 1.3):
- 783564 lines of PHP (in 3110 .php class files and 617 .phtml template files)
- 474182 lines of XML (in 120 configuration files and 41 layout files)
- 77426 lines of JavaScript (in 61 files, some of it is from Ext or Prototype/Scriptaculous)
- 53430 lines of CSS (in 7 files)
- Quite a lot of SQL hidden away in .php files.
That’s quite a lot to choke on. While it isn’t necessary to read each and every line of XML, JavaScript, PHP or CSS, one will read through quite a lot of them while modifying templates and design and yet much more when developing additional modules for it.
Since there’s so much stuff going on here, you’ll quickly learn to value good development tools, for things like debugging, code browsing, CSS inspection and so on.
Here’s what I did:
- Installed the Xdebug PHP debugging extension. This extension communicates with a PHP debugger to inspect variables (which is very helpful for the complex nested classes Magento uses), set breakpoints, step through the code and so on.
- Installed Magento 1.3. I use the full download installation method, but as long as you meet the server requirements, installation should proceed painless.
- Installed PHPEdit (Windows only). This PHP-centric web development IDE has a good debugger (including a Firefox extension to switch on/off the debugger) and is especially suited for large projects. A little extra feature of it is that it can dynamically blend in/out different code languages in the same file, which is very helpful for .phtml templates, which contain a wild mixture of HTML, PHP and JavaScript.
- Installed a current Firefox (3.5), the Web Developer extension, Firebug and it’s addon FirePHP
- Headed over to Active Codeline, grabbed the Firebug logging code and placed it in the Magento index.php
- Activated the JIT JavaScript compiler options in Firefox by opening about:config, typing jit into the search bar, and set both options to true. The result is that the chrome internal JavaScript engine becomes a lot faster, which makes FirePHP much more responsive while displaying huge, deeply nested Magento objects. Saved me a lot of time and nervous breakdowns.
- Installed Cygwin (again, Windows only). This gives me basic UNIX power on Windows (something that is really handy because a lot of useful (PHP) scripts are for the UNIX environment). It’s also a requirement for my primary IDE, the TextMate clone
- e Text Editor. I like this editor because of its simple code snippet functionality, which is really useful for boilerplate code and the like; and it’s Windows Explorer integration which allows usage of Shell plugins, like
- TortoiseSVN. This handy tool allows using SVN directly from the Windows Explorer. If SVN is not your favorite version control software, there are also Tortoise implementations for CVS, Git and Mercurial and probably a few others. Using version control has multiple benefits, the less obvious I will talk about later (in another post).
- Another really handy tool for dealing with the enormous amounts of text Magento throws at you is a full text search utility. I use dnGREP for its Explorer integration and overall speed and ease of use.
- With the deep file hierachies of Magento and multiple tools we’re using to work on it, we need a quick and easy way to get the path of a file or directory into the clipboard. Ninotech PathCopy is a simple and good tool that allows exactly this via – you guessed it – an explorer context menu entry.
- Last but not least, more complex Magento extensions will require some reverse-engineering of the SQL queries Magento generates. The MySQL GUI tools are invaluable here.
Now, this setup is quite huge, but now you can sift through code and debug Magento with relative comfort.
So the “basic” environment is covered now. Of course, there are many tools I didn’t mention, like FTP and SCP programs, but I assume everyone of the audience (I’ve got one, right? …right??) has their own preferred tools.
The topic for the next article isn’t decided yet, but it will probably be about the Magento architecture. Stay tuned!