We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Susan, I find that a lot of things that used to take me hours to find went away when I started using JetBrains' PhpStorm. Its code inspection is nothing short of amazing. For example:

    
    if (isset($scriptProperties['useFilter']) && $scriptProperties['useFilter'])) {
        $userFilter = true;
    }
    
    $resource = $modx->getObject('modResource', 12);
    if (! $resource) {
        return('Failed to get resource');
    }
    
    /* lots more code here */
    
    if ($useFilter) {
       filter($resource);
    }
    


    PhpStorm will flag the $useFilter at the bottom as an error. When you hover over it, you get a message: "$useFilter may not have been set."

    My "projects" always include the entire MODX core (I put my code in assets/mycomponents). PhpStorm has the whole core and my code indexed. I can right-click on any MODX method and jump to the function declaration in a new window, wherever it is in the core. I can also right-click in the project tree and do fairly fast regular or regex searches of the entire core or any subdirectory and get a list of links I can click on to open those files with the cursor at the search term.

    It does type checking for arguments to your functions and MODX methods, and more directly relevant to your suspicions, it highlights misspelled variable names in both directions. A variable that's used but hasn't been set gets highlighted, *and* a variable that is never used or that gets its value changed before it is ever used is also highlighted.

    It also has fairly impressive code inspection for HTML, JS, and CSS.

    The only down side is that it takes a long time to load. Once it's up, though, it's plenty fast.

    I resisted giving up my old favorite editor for a long time, but I wish I has switched sooner.


    ------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using.
    MODX info for everyone: http://bobsguides.com/modx.html
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      <whimper>

      Actually, I do have this, I just keep giving up on it when I need to get something done and don't have the time or energy to figure out how to use the thing.

      Ah, turns out I have the demo version. Never got to the point of being willing to use up three months worth of yarn or quilt fabric orders to pay for it. [ed. note: sottwell last edited this post 14 years, 2 months ago.]
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 3749
        • 24,544 Posts
        Yikes. I just left you a long message on using PhpStorm and the forums logged me out when I tried to save it.

        Here is what I can remember:

        I recommend making a dedicated MODX install for it. After creating the site, Just go to File -> New Project. Give it a name and browse to the MODX root directory. Once it's there and you've done any work in it PhpStorm should open looking just like it did when you closed it.

        Put your own code under the MODX assets directory. Just right-click on a directory in the project tree at the left and select "New" to create a file or directory under it.

        Double-click on a file in the project tree to edit it. Hit Ctrl-s to save. Most of the keyboard shortcuts are fairly standard. Right-click on the code and select "Run" to run it.

        The only catch I can think of is that if your code creates a file, you need to right-click on a directory above it in the tree and select "Synchronize" to see it.


        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I'll definitely give it a try.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org