Magicento is a free PHPStorm plugin for Magento developers. Features include:
Goto for factories and template paths, autocomplete for factories, xml files and class names, documentation for xml nodes, evaluation of PHP code inside Magento environment, and much more to come!
Using PHPStorm 6+ (*) you will get code completion for factories automatically (just use Ctrl+Space like always).
This is useful not only for code completion but also for "go to declaration" feature (just use Ctrl+B / Ctrl+Click / middle click (windows)).
It works for $this->helper() inside templates and $this->_factory->getModel|getHelper|getSingleton|getResourceModel too
* If you are using an old PHPStorm version, you can have code completion using "add @var" action:
with the cursor over your $variable use Alt+M (Option+M)
PHPStorm 6+ required (with older versions you can use Alt+M > add @var $this on any .phtml file).
Make sure you have enabled this option inside Magicento settings.
Note: sometimes is not possible to find the correct Block for the current template (for example when the template is not assigned with the layout.xml but is hardcoded inside the Block class, or when you have wrong package/theme in Magicento Settings)
Just use Ctrl+Space after the "class " keyword
It works for controllers too
Note: this could be a big time saver because your class names won't have typo errors anymore, also is very useful when you need to refactor some module name.
Use Ctrl+Space after the "extends " keyword.
Use Alt+M when the edit cursor is inside the class you want to rewrite and select Rewrite Class or Rewrite Controller.
Then select the target module where the new class will be created.
And lastly you can change the default class name (proposed by Magicento) for the new class.
When you are rewritting a controller the dialog is a bit different:
The prior dialog will generate a class and xml like this:
Note: the only requirement for these actions is to have a valid target module already created, with a config.xml file (config.xml can be empty, Magicento will create the correct nodes)
Use Alt+M anywhere inside any opened file and select Create Module
The options are self explanatory
The "Group" field can be empty and it will use the default one (NAMESPACE_MODULENAME), in the image above the default group is "magicento_test" but it was changed to "mtest"
You can choose if you want to generate the nodes and folders for the blocks, models, helpers (in this case it will create a Data.php file too) and installers.
These are the files generated by the prior dialog:
Use your "Go to" shortcut (by default Ctrl+B / Ctrl+Click) on any string representing a factory to jump to the class for that factory.
This works everywhere:
Mage::getModel('[CTRL+B HERE]')
<block type="[CTRL+B HERE]" ... >
$this->_init('[CTRL+B HERE]')
etc
Use your "Go to" shortcut (by default Ctrl+B / Ctrl+Click) on any relative path to some file.
For example
<block ... template="[CTRL+B HERE]" >
<file>some_layout_file.xml</file>
Use your "Go to" shortcut (by default Ctrl+B / Ctrl+Click) on any string representing a block name/alias or handle name.
For example
<reference name="[CTRL+B HERE]">
<update handle="[CTRL+B HERE]">
$this->getChildHtml('[CTRL+B HERE]')
$this->getBlock('[CTRL+B HERE]')
Use Alt+M when the edit cursor is inside a Block class and select the action Goto block definition in layout
Note: sometimes Magicento can't find the <block> nodes where the Block class is used. This happens for example when the block is created from PHP instead of using the layout (adminhtml grids for example).
Use Alt+M when the edit cursor is inside a Block class and select the action Go to template from block
Note: sometimes Magicento can't find the .phtml file/s where the Block class is used. This happens for example when the template is assigned with PHP instead of using the layout.
Use Alt+M when editing some template (.phtml) file and select the action Go to Block
Note: sometimes Magicento can't find the Block class reference by $this in the .phtml file. This happens for example when the template is assigned with PHP instead of using the layout.
Use your "Go to" shortcut (by default Ctrl+B / Ctrl+Click) on the event name inside any Mage::dispatchEvent call.
Mage::dispatchEvent('[CTRL+B HERE]')
Note: at the moment this works only for constant/hardcoded event names
Use Ctrl+Space), for example:
Mage::helper('[CTRL+SPACE HERE]')
This works with $this->_init([CTRL+SPACE HERE]) inside Models and Collections too
Use Ctrl+Space) with ->getTable calls, for example:
This works with $this->_init([CTRL+SPACE HERE]) inside ResourceModels too
Use Ctrl+Space) with Mage::getStoreConfig, for example:
Note: this works part by part, you probably need write a forward slash "/" and use Ctrl+Space again to get the final desired config path
Use Ctrl+Space with:
$this->getChild('Ctrl+Space')
$this->getChildHtml('Ctrl+Space')
$this->getBlock('Ctrl+Space')
$this->getBlockdHtml('Ctrl+Space')
Use Ctrl+Space inside any config.xml:
Tip: try to use it always, on any level, for nodes and also values.
Use Ctrl+Space inside any system.xml:
Tip: try to use it always, on any level, for nodes and also values.
Use Ctrl+Space inside any adminhtml.xml:
Tip: try to use it always, on any level, for nodes and also values.
Use Ctrl+Space inside any /layout/*.xml file:
Tip: try to use it always, on any level, for nodes, attributes and values.
Use Ctrl+Q when the cursor is over some node name or attribute name to get some brief documentation.
Note: at the moment not all the nodes and attributes are documented
Magicento will search rewrite conflicts automatically and will show you an alert if somo conflict is found
Use Alt+M when editing some .phtml and select the action Copy Template
Then you need to select the target Package and Theme (*), a new file with the same relative path will be created there.
* At the moment this only works for existent themes (so you need to create the folder first if you want to use a new Theme)
Use Alt+M when editing some file located in /code/local/Mage or some .phtml/.xml and select the action Compare with Original
Use Alt+M when editing any file and select the action Evaluate in Magento
Write the PHP code to evaluate (it will be executed inside your Magento so you can use Magento code)
By default the code is evaluated inside a "var_dump" call, that's why you don't need to put the semicolon, and you can evaluate just one sentence.
But this can be changed from Magicento Settings
When you are not using the "var_dump" option you can write any PHP code, but if you want to see some output you need to call "echo" (or some output function) by yourself.
Use Alt+M when editing any file and select the action Toggle Template Hints
This action will toggle the template hints for the frontend and also the backend in your current Magento
Use Alt+M when editing any file and select the action Fluch Cache
This action is very useful when you are developing with the cache enabled
Use Alt+M when editing any installer script (.php files inside /sql and /data folders) and select the action Remove this installer from core_resource table
This is useful when you want to run again some installer script
The core_resource table will be reseted to the prior script version so when you run Magento again the script will be executed automatically
Use Alt+M when the edit cursor is over some config path inside any Mage::getStoreConfig call and select the action Get Store Config
You can do the same evaluating the code with Alt+M > Evaluate in Magento
To obtain the specific value for some store, you need to set the current store from Magicento Settings (or use Alt+M > Set Store)
Select the text inside any .phtml file, use Alt+M and select the action Translate TExt
TIP: put the cursor in some part of the text to translate and use Ctrl+W to select the whole string quickly
Use Alt+M when the edit cursor is over some translated string and select the action Add Translation
Then type the translated text and select the translation .csv type (if you choose translate.csv and the file doesn't exist in the selected theme, it will be created)
Magicento includes the Magento dictionary from here: https://github.com/tim-bezhashvyly/phpstorm-magento-dictionary
If you think Magicento is useful for your work please consider making a donation.
Thanks in advance!
These videos are a bit out of date but they could be useful if you want to see Magicento in action
Go to File > Settings > Magicento
Magicento will work automatically on your Magento projects (if not please check the configuration going to File > Settings > Magicento).
You have only one shortcut: Alt+M (Option+M on mac). This shortcut is context aware, that is, you will see different options depending where the cursor is (a var definition, a .phtml file, a Block class, an intaller script, an xml etc).
The rest of the features from Magicento are accesible using the original shortcuts from PHPStorm (Ctrl+Space for autocomplete, Ctrl+B | Middle Click | Ctrl+Click for "Go to..", Ctrl+Q for documentation).
Please read the Features (really important to take advantage of Magicento)
If you install Magicento from the repository, the IDE will alert you when a new version is released.
Also you can follow @magicentoplugin on twitter, I will inform about updates there too.
Seguir @magicentoplugin
Please use the issues tab on github: https://github.com/enriquepiatti/Magicento/issues. If you don't have a github account send an email to "issues at magicento.com" describing the issue, with the full trace of the exception if it's available.
You can request, comment and vote new features clicking the "suggestions" box in the middle left of this screen
You can uninstall it from the plugin section on the settings panel of the IDE. Or if you want to disable it just for the current project goto "magicento" section inside the settings of the project and disable it from there.
If for some reason you can't do that (maybe the IDE hangs up or you can't start it), then you can disable it by adding this line to /.idea/magicento.xml:
<option name="enabled" value="false" />
As a last option, you can also search for "magicento.jar" in your hdd and remove it, in Windows for example it is normally located at: [USER_FOLDER]\.WebIde60\config\plugins\magicento.jar
Try first uninstalling Magicento: How to disable Magicento?
If that doesn't work try removing PHPStorm logs too (in windows for PHPStorm 6+: [USER_FOLDER]\.WebIde60\system\log\)
If that doesn't work either try removing indexes, or remove the /.idea folder from your project (the IDE should start correctly if you don't start it with an opened project, and then you can remove or disable Magicento from there).
And don't hesitate to contact me by email: contacto@enriquepiatti.com or skype: enriquepiatti.
Also please remember to submit the issue (How to inform about issues/problems?), and I will try to fix it ASAP
Because I've tested a lot of IDEs and even when it's not perfect, I think it's the best option in the market
Magicento was successfully tested on PHPStorm 3, 4, 5, and 6 using Windows, MacOs and Linux.
But the latest version doesn't work well in PHPStorm 3 and 4. I recommend to use always the lastest PHPStorm version (some features will work only with PHPStorm 6+), but if that's not possible you can download a prior version of Magicento and install it manually.