We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15861
    • 24 Posts
    Hey all,

    Through a couple of custom apps that I’ve built for clients I’ve gotten very comfortable using SVN during the development process. Now that I’m moving into a new company, I get the chance to help finalize some working processes, and I would like to have some form of version control in place for all sites that we work on. And we all love ModX, but the problem that I’m seeing is that with ModX saving everything in db, how do I get a good process in place that takes as much human error out of the process as possible? Yes, I realize that we’re all human and prone to mistakes, but making some do a backup of the db, put it in the right place on the dev server, then upload all of the contents to the SVN server is one or two steps two many. If all they have to do is open Versions and hit the commit button, it’s more likely to happen.

    Has anyone worked up a good system for this? If so, could you share the process you use?

    Thanks in advance!
      • 26903
      • 1,336 Posts
      There are utilities that back up a MODx site into a zip file, this includes an sql file dump of the database, you could do this regularly and just commit it to SVN say. I think one called MODbak, but there are others, search the resources section for more info.
        Use MODx, or the cat gets it!
        • 25663 MODX Staff
        • 12,272 Posts
        I hear you kilishan, this is one of the toughest parts of working in team environments and using version control. You can do what we’ve done a lot which is include your code and store it on the filesystem. We’ve done this a lot lately and a call looks like the following. First you need the include snippet:

        <?php
        // &file=`assets/foo/bar.php` indicates the file to include
        // &return=`1` return explicit content from return statement in included file
        //  default behavior is to use output buffering to capture the content from the include
        
        $output = '';
        if (isset($file) && file_exists($file)) {
            if (!isset($return) || $return == false) {
                ob_start();
                include ($modx->config['base_path'] . $file);
                $output = ob_get_contents();
                ob_end_clean();
            } else {
                $output = include ($modx->config['base_path'] . $file);
            }
        }
        return $output;
        ?>


        Then a sample call might look like the following:

        [!include? &file=`assets/app/dashboard.main.php` &param1=`foo` &param2=`etc`!]
        


        Or, for a form:

        [[include? &file=`assets/app/chunks/Form.Status.chunk.html`]]
        


        This way you can keep your application code or important frequently updated content on the filesystem managed by subversion. It’s not perfect, but it’s an improvement that’s helped us tremendously.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me