Let’s add another wrench to our magneto developer toolbox console php
How many hours a week does the average Magento developer spend editing a test file, refreshing the page, and editing the code again to fix one more thing?
I am always trying to find new tips and trick to speed up Magento development whether using MageTool or code wrappers/snippets in PHPStorm. Even those tools have their limits. XDebug can really help troubleshoot faulty code, but stepping can be tedious and time consuming. I would like to introduce a project that I just started on github that was forked from a simple php console that integrates with Magneto. Its pretty simple really.
This tool allows developers to test code by simple inserting php code into the console and hitting ctrl+enter. The code is evaluated via ajax and the response is displayed in an output window. This can be useful when looking for simple things like proper attribute codes. The tool is also useful for testing quickly refactored code and modularly testing functions within a class.
Personally, the tool has helped me write cleaner code, because development can be accomplished in a test-driven manner. Functions are cleaner and provide a more clear role because of the ease of testing.
The code behind the scenes simply loops through all the directories up a level and adds those to a project menu in the application. Clicking on one of the projects includes the Mage file and allows all code to be executed in the specific project’s instance.
But wait there’s more….the console also has support for saving snippets in LocalStorage. The snippets names are a combination of the current project and the name provided by the developer.
- Clone project from github in your root sites directory (for me its home/username/sites/).
- Create vhosts for site.
- Map hosts file for site.
- Go to site in browser.
I am sure that everyone would like to see support for Gists, Rich Snippets, Auto-completion and lots of other features. Please contribute!