We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40358
    • 40 Posts
    So, I am sure there is a cool way to do this, but I have absolutely no idea how to.

    I am developing an extra and I am having a hell of a time trying to cope with ignoring the correct directories etc to make everything work. To avoid including some of Modx's core I ignore

    /core
    /assets


    And this of course makes life hell when I try to unignore the subdirectories for the extra.

    So my question is rather simple. I've seen people talk about their development setup, but noone (as far as I can tell) has in details shared how to do this the "right" way.

    Someone enlighten me, please smiley

    - Thomas

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      I put all projects under assets/mycomponents/projectname. They're all inside the same MODX install.

      Each project has its own local git repository, created by navigating to the project directory and doing "git init". I have a set of aliases in the .bash_profile file in my user directory that let me go to a project directory. For example, this lets me jump to the NewsPublisher project by typing "np":

      alias np="cd /c/xampp/htdocs/addons/assets/mycomponents/newspublisher"


      If there's anything in the project that should be ignored, you can create a local .gitignore or .git/info/excludes file. The advantage of the latter is that Git ignores the .git directory automatically so you can change the excludes file whenever you like without the changes showing up in Git status.


      The down side of this is that you can't use Git to update MODX itself or to issue pull requests. You can, however, use Susan's script to update MODX or just download and unzip the files, and you can run setup as you normally would.

      The up side is that I can search all of MODX and/or all of my projects when looking for something. PhpStorm indexes the whole thing, so the search is fairly fast and I can jump instantly to the declaration of any method or function by putting the cursor on the name and pressing Ctrl-B, regardless of whether the target is in my code, xPDO or MODX. After looking at the function code, Ctrl-Alt-left-arrow will take me back to where I came from.

      MyComponent, BTW, will set the whole project up for you (minus the "Git init") in assets/mycomponents. You just have to edit the one config file and run bootstrap.




        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
        • 40358
        • 40 Posts
        I am sorry Bob but I still don't fully understand how to do this the proper way.

        You say you put files under assets/components/proctname, but what about the files needed for the core? Or _build? To get the structure correct for the Extra, you will either way have to init the repo in the modx base directory.

        I might not have pointed this out when I posted the thread, the actual problem is ignoring and removing files from "untracked files", so I can simply do git add --all to add all the files I want.
          • 40358
          • 40 Posts
          Okey, so I fixed it. I wrote a comprehensive guide for my setup.

          It is located right here: http://www.optimuscrime.net/en/blog/63-developing-an-extra-git-and-.gitignore
            • 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
              I don't understand why you wouldn't want to have the _build files under version control. That doesn't mean they'll be part of the package, but it's nice to have access to previous versions of them.

              You say you put files under assets/components/proctname, but what about the files needed for the core? Or _build? To get the structure correct for the Extra, you will either way have to init the repo in the modx base directory.

              No, definitely not. I have about 50 extra projects under assets/mycomponents/. They all work fine there and the packages work fine when installed. Many of them can also be run in my editor (PhpStorm).

              This makes them use the local files during development and the installed files for users. It's used for all class, CSS, and JS files:

              require_once $modx->getOption('nf.core_path', null, $modx->getOption('core_path') . 'components/notify/') . 'model/notify/notify.class.php';


              This makes them work in the editor:

              if (! defined('MODX_CORE_PATH')) {
                  require_once 'c:/xampp/htdocs/addons/assets/mycomponents/instantiatemodx/instantiatemodx.php';
              }


              It can be removed before distribution, though it's harmless inside MODX.

              If your project is at all complex, I urge you to try MyComponent. Its help with lexicon strings alone is worth the effort. It will build stubs for all your files complete with custom author and copyright notice, PhpDoc blocks, and a customizable license statement.

              MC will let you make changes in MODX and export them to your files, and vice versa. It will also let you use static files during development and turn that setting off automatically when the package is built.

              MC comes with a universal build.transport.php file that works as is for at least 95% of my extras (it also automatically handles subpackages, validators, and resolvers).

              At MODXpo, I created a complete, distributable package with a resource, a snippet, a Tpl chunk, snippet properties, and lexicon strings. It took less than 20 minutes, including writing the code.



                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