We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23510
    • 168 Posts
    Hi everyone

    What is the recommended workflow for MODx sites that need to be live 24/7 but you need to be doing active development? E.g. with normal resources, its not a problem. Copy a resource, edit it, preview it when logged into the manager. But when it comes to resources that need to use multiple snippets, templates, chunks etc, how can you preview your work without affecting the live site?

    For normal file based sites, it works to have your files and database locally for testing. Then after making changes, use git to update your local repository and push to the remote repository, then do a pull on the server.

    MODx is a little quirky in that copying the files and database are not enough. You also have to keep track of what chunks you changed, and if you are installing an addon, install it on the remote server too, etc...there is just more to manage mentally. I believe you also have to do a reinstall if you are copying the database from local to remove.

    What I'd like to see is this.

    You have MODx installed locally. This installation then connects to the remote MODx which downloads all resources and elements to your local system (files as well), then you make changes which then need to be pushed to the remote system.

    Honestly I don't know how practical something like that will be. So please give me your comments please! And let me know what you're doing now to cut down on having to take a live site offline to work on it.

    Thanks
    John
      • 1650
      • 18 Posts
      Hi John

      This is as topic that's bothered me for some time also - I've never really resolved how we go about coding snippets, chunks etc. using our IDE of choice and apply source control to the work. We've done a lot of custom development on a lot of sites, and frankly, for developers writing and testing code, it's been torture.

      I'd like to see some progress in this area - even if we can just get together some best practices based on life in the trenches and each other's experiences that make ease the process of developing and maintaining development heavy sites.

      A.
        • 23510
        • 168 Posts
        Thanks a lot for the reply Andy!

        MODx is almost like an IDE now, when you're doing custom work. I usually have two MODx tabs open in my browser for the same site. This helps me to quickly switch between resources and elements, or between chunks and snippets. Quick editing an element helps a lot too but I find that I do need the extra tab.

        John
          • 1650
          • 18 Posts
          Really John - do you think it's like an IDE?

          Apart from there being no decent code editor, no syntax checking/highlighting, debugger, support for source code management, etc. etc.

          This is not a complaint - I don't believe it's modX's problem to do these things - but it would help developers like us who are trying to make modX do complex applications or developing plugins for example, to facilitate the use of phpStorm or Netbeans somehow for working on templates, chunks, snippets etc.

          We've all got our techniques for making it work for us (like your multiple tabs set for resources/elements which I'll be trying this afternoon!) and I'm sure someone out there may well have solved this already and hearing how they work will be a great help.

          Alternatively we're just limited in what we can achieve with modX and the point at which we have to go to Symfony or Ruby/Rails for a project is closer. I ideally want to develop as much as possible in modX, and not have to look at leaving the environment for something like the membership database I'm developing at the moment - but sometimes I look at the way we're working with modX and think we're making our lives more difficult, not easier by sticking with it instead of using Symfony/Zend/Whatever....

          And as you point out, then there's the issue of deployment.

          A.
            • 23510
            • 168 Posts
            Ok to correct myself, its not like an IDE but it is getting to the point where it will benefit from IDE-like functionality.

            Whether that functionality is practical or not, is another matter.

            E.g. it would be great, if you had a chunk call inside a resource, to right click on it and choose "Quick edit chunk", and it opens up.

            Or right click on a chunk or snippet in the Elements tree, and choose "Show usages" but I was told that it would be impractical as there could be calls to it inside PHP code inside snippets.

            John

              • 33968
              • 863 Posts
              Are you guys writing all your snippet code within the MODx manager? No wonder you're finding it tough smiley

              Have a look at this:
              http://rtfm.modx.com/display/revolution20/Snippets#Snippets-WriteyourSnippetsoutsideofMODx.

              You can then sync your file based snippets from dev to production servers without having to go into the MODx manager at all. You can quite easily keep all your code in a version control repository this way too.

              Apart from there being no decent code editor, no syntax checking/highlighting, debugger, support for source code management, etc. etc.
              There is CodeMirror for syntax highlighting. It's not perfect but it does make scanning your code/markup much easier. [ed. note: okyanet last edited this post 14 years, 9 months ago.]
                • 23510
                • 168 Posts
                Thanks Lucas.

                Will definitely look at that.

                John
                  • 1650
                  • 18 Posts
                  Thanks Lucas - this is exactly the sort of help I'd been looking for.

                  A.
                    • 38121
                    • 36 Posts
                    I'm new to modx and currently develop my first website under Revo 2.2. Sometimes I love it and sometimes I pull my hair off my head, mostly because of the code editing workflow. Having to edit everything from the admin and reload the front-end makes it super slow while going through a trial and error method. So I use a few methods to go around it.

                    - If I need to edit code directly from the browser (almost never happens), I use Quickcursor (https://github.com/jessegrosjean/quickcursor"" target="_blank" rel="nofollow">git). It grabs the code, and opens it in my favorite text editor. Save and close the text editor window, the code is injected back into the browser. I'm using it to write this post. Neat smiley It's on Mac only, if you don't want to compile the app, get it from the http://itunes.apple.com/fr/app/quickcursor/id404035899?mt=12"" target="_blank" rel="nofollow">Mac App Store. For Windows users, there is a Firefox extension that does the same but I can't find its name right now.

                    - My favorite is https://github.com/digitalbutter/FEM#readme"" target="_blank" rel="nofollow">FEM, an extension written by DigitalButter. It mirrors a directory structure of chunks, snippets and templates on the file system into modx Revo. It creates whatever needs be created and updates whatever changed. It even creates categories and TVs for you. One install modx was corrupted and using FEM, it took me two seconds to recreate all my snippets, chunks, templates, categories and TVs. Awesome!! It's in alpha version but its very solid. Digital Butter wrote https://github.com/digitalbutter/MODX-Mirror"" target="_blank" rel="nofollow">modx Mirror which replaces FEM and which I'll use once I figure out how to make a transport package (if anyone knows how to, please feel free to share). I still wonder why FEM/Mirror wasn't submitted for inclusion in the modx extras website.

                    - Lastly I use the https://forums.modx.com/thread/73493/development-workflow#dis-post-408387"" target="_blank" rel="nofollow">method pointed out by Lucas. I wrote a helper snippet which I call from snippets, chunks or templates (uncached!). Inclusion path are preconfigured so I only pass the file name, not the path. I noticed that in some rare cases modx cache needs to be emptied manually.
                    Combine this with FEM/Mirror and you almost never need to go back to the admin anymore for code editing.

                    Hope this helps.
                    Jerome [ed. note: yogooo last edited this post 14 years, 9 months ago.]
                      • 3749
                      • 24,544 Posts
                      FYI, in MODX Revolution, you can edit pretty much any object in the tree (resource, chunk, snippet, plugin, etc.) in a popup window with the built-in Quick Edit choice when you right-click on the object in the Tree. No RTE there, though.


                      ---------------------------------------------------------------------------------------------------------------
                      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
                      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