Archived video

This video is archived and won't be updated. We're keeping it online for now as a courtesy.

Alternate resources: 

Use Pantheon Environments

Video loading...

  • 0:00
    Manage Drupal Sites with Pantheon Use Pantheon Environments Addison Berry
  • 0:09
    So Pantheon gives us 3 environments
  • 0:12
    to control our workflow on our site.
  • 0:17
    In this lesson, we're going to actually begin using those environments.
  • 0:22
    Now, you get a Dev environment when you start your site on Pantheon.
  • 0:26
    We're going to go ahead and create the Test and Live environments
  • 0:28
    that we'll need, and then we will go through
  • 0:31
    the process of making updates to the live site
  • 0:33
    using Dev, merging those changes into Test,
  • 0:38
    and then deploying that code out to Live,
  • 0:40
    and then we'll look at how you can pull your live database content
  • 0:44
    down to Dev to make sure that your Dev environment
  • 0:47
    is sort of staying up to date with the latest of what's happening
  • 0:49
    out on your Live environment.
  • 0:51
    So let's take a look at this.
  • 0:54
    So I'm in the dashboard here for a website
  • 0:57
    that I have just gotten started.
  • 1:00
    I have the Dev environment, of course,
  • 1:02
    which is started for me, but I don't yet have
  • 1:04
    my other environments, so let's go create Test and Live
  • 1:09
    and get the whole site sort of up and going.
  • 1:11
    We already have an existing site, so it's working—
  • 1:14
    there's stuff on it and content and things like that
  • 1:17
    has all happened in Dev. Then when it comes to Test,
  • 1:19
    I need to create the environment.
  • 1:21
    Notice it's going to clone the entire development environment.
  • 1:25
    This is not just the code— this is the entire environment,
  • 1:28
    including the database and files, so all of the work that I have done on Dev
  • 1:32
    will be created in a test environment the first time,
  • 1:36
    when you very first create the environment.
  • 1:38
    So let's go on and click that, and then that'll take a few minutes,
  • 1:41
    which we're going to accelerate a little, to get that environment
  • 1:44
    copied over for you.
  • 1:47
    So once we have the test environment created,
  • 1:50
    you'll see we get the same thing.
  • 1:52
    We have our commit log. It just brought everything over.
  • 1:54
    And now we have a new Deploys tab, and you can see
  • 1:58
    that we have the test environment created here.
  • 2:00
    We're going to need to do the same thing with Live.
  • 2:02
    We want to get this site all the way up to Live and published,
  • 2:05
    so after you've tested it, we'll go over to Live.
  • 2:08
    You can't create a live environment until a test environment exists.
  • 2:12
    It just won't work, so you have to do it in this order.
  • 2:15
    So let's go ahead and we're going to do the same thing here,
  • 2:17
    and again, it'll take a few minutes.
  • 2:19
    So now all of my work that I've done in Dev
  • 2:22
    is finally gone through the pipeline and is live.
  • 2:25
    So now I have all 3 of the environments in place,
  • 2:28
    and that fully functioning website with all of its database and configuration
  • 2:31
    and everything is identical in all 3 environments right now
  • 2:35
    because we've just been cloning.
  • 2:37
    Now that we have something live, we want to do ongoing development,
  • 2:40
    and so now we're going to enter into your standard workflow
  • 2:45
    with the Pantheon environments here.
  • 2:47
    And so what I'm going to do is go back to the Dev environment
  • 2:50
    and I'm going to hack on some code in here
  • 2:55
    and make some changes.
  • 2:57
    So I'm going to move over to my command line.
  • 2:59
    I'm going to be using Git— you can use SFTP or Git.
  • 3:02
    All the development you've been doing, it's the same process
  • 3:06
    of modifying the code, so I'm just going to go modify some code
  • 3:09
    and come back, and then we'll see how to move that code
  • 3:11
    up through the environments.
  • 3:13
    So I'm logged in; I'm on the master branch here
  • 3:16
    for the Dev environment, and so I'm just going to do
  • 3:20
    a very simple code change here where I'm going to add
  • 3:23
    some modules that we need on the site,
  • 3:26
    and then I'm going to go ahead and commit that stuff
  • 3:29
    and then push them back up to the master branch.
  • 3:39
    So I've made changes to my master branch on Dev.
  • 3:42
    Now let's go back to the Pantheon UI.
  • 3:44
    And you can see in the Commit Log that my commit is here,
  • 3:48
    and it says that it is ready to pull into Test.
  • 3:51
    So if we go we can either click this or I can go to the Test environment here,
  • 3:57
    and under the Deploys tab now, in addition
  • 4:02
    to the previous entry we had, we have it showing us
  • 4:05
    that we have a commit that is ready.
  • 4:07
    If there were multiple commits, they would all be listed here.
  • 4:09
    So let's just look at these options real quickly here.
  • 4:13
    So running update.php, these are just sort of best practices, right?
  • 4:16
    Clearing cache—so you probably want to do those things,
  • 4:19
    but if you don't, you can uncheck them.
  • 4:21
    Now, this is not checked by default,
  • 4:24
    but this is probably a good idea— again, it depends on your workflow
  • 4:28
    and what changes you're actually putting out, but we want to pull the files
  • 4:31
    and database from the live environment.
  • 4:33
    So remember, I just made a code change on Dev,
  • 4:38
    and when I do this deployment on a test,
  • 4:43
    all I'm doing is pulling the code.
  • 4:46
    I am not pulling in any of the database stuff.
  • 4:49
    And the reason it's asking for a database in Live environment is,
  • 4:53
    of course, if this code is eventually going to live on the Live environment,
  • 4:57
    we'd like to make sure that the code
  • 5:00
    that I just worked on also works with any updates
  • 5:03
    that have been happening on the live site,
  • 5:05
    so we want the latest and greatest version of the live site
  • 5:08
    when we do our testing.
  • 5:10
    So I'm going to go ahead and check this because I would like to merge this.
  • 5:13
    Now, one other thing I want to point out as we do this—
  • 5:16
    If there were configuration changes that needed to happen—
  • 5:19
    again, we're not pulling the database— so I would need to account
  • 5:23
    for configuration changes in other ways, so I have added these modules,
  • 5:26
    but if I actually configured them on my Dev site,
  • 5:28
    that wouldn't get pushed up, and so in Drupal,
  • 5:31
    the typical way of handling moving those things
  • 5:34
    is to put configuration changes into code using
  • 5:36
    a tool like Features or you can write update hooks.
  • 5:40
    There's a whole API for doing updates,
  • 5:43
    and you could manually write the code to make those changes.
  • 5:46
    Or, of course, you could also just have a checklist
  • 5:49
    of okay, once you deploy this, click these buttons and do that thing.
  • 5:52
    Best practices is to try to get as much of that configuration into code,
  • 5:57
    so when I do this code deployment in a test,
  • 5:59
    it's just there and nobody has to do something.
  • 6:01
    But that's something you just need to be aware of.
  • 6:03
    This is a code update to Test.
  • 6:07
    That's all we're doing here, so nothing else I did
  • 6:09
    on the development side is going to come forward.
  • 6:11
    And so once I have everything ready, I put a little log message in here
  • 6:16
    for this deployment, and then it tells me in the button,
  • 6:20
    as you change things up here, it'll change the text in the button.
  • 6:24
    So I'm going to copy content from Live
  • 6:26
    and I'm going to deploy code from Development.
  • 6:29
    I'm going to bring both of those objects together
  • 6:31
    into the test environment.
  • 6:33
    So once you click this, again, this will take a few minutes,
  • 6:36
    and then we'll have all of our stuff fresh and ready to QA on Test.
  • 6:40
    So that's it— I've now deployed it.
  • 6:44
    It has our little log message that we put here,
  • 6:47
    and now the test site has combined
  • 6:51
    kind of all the latest and greatest from all of the environments
  • 6:54
    so that we can now go do QA, get feedback and things like that.
  • 6:57
    Another good thing to sort of think about or be aware of,
  • 7:00
    especially with Test, before we go to deploy this to Live,
  • 7:04
    which will be our next step here, is there's this Status tab,
  • 7:09
    and you can run a check, and this is sort of a list
  • 7:13
    of best practices checks on the site
  • 7:15
    that Pantheon will run for you to let you know if there are any red flags
  • 7:18
    or things that you should be really aware of on this.
  • 7:21
    And so you can see we have just a bunch of basic checks.
  • 7:25
    You can see these red things are because I don't have caching enabled,
  • 7:28
    so a lot of this is about, make sure you get the best performance
  • 7:31
    out of your site, not necessarily things
  • 7:34
    that are like, oh, my gosh, this site is broken,
  • 7:36
    but things that we probably want to look at and investigate
  • 7:39
    before we go live or that we should make sure
  • 7:42
    that these are on our live site, because this database
  • 7:45
    and a lot of this stuff is coming from a live site.
  • 7:47
    But just so you know, you can check that status,
  • 7:51
    which is kind of nice when you're in that test phase.
  • 7:53
    Now, let's go ahead and just deploy this to Live,
  • 7:55
    assuming that everything's looking the way that we expect it to.
  • 7:58
    So I'm going to go to my Live environment
  • 8:00
    and go to Deploys.
  • 8:03
    So you can see we have one commit that is ready to deploy
  • 8:06
    from Test, so we want to grab that stuff that was in Test
  • 8:09
    and bring it forward up to Live.
  • 8:11
    Our options are similar to before, except, of course, there's nothing
  • 8:15
    about a database, because, well, we don't want to mess with the live database.
  • 8:18
    It stays. It's the canonical source.
  • 8:20
    So we're just going to leave that, and again, we can add
  • 8:24
    a log message,
  • 8:27
    and then we'll go ahead and just deploy this
  • 8:29
    out onto our live site.
  • 8:32
    And boom, just like that, the code changes that I made
  • 8:36
    on Dev have moved all the way up, been QAed,
  • 8:38
    and are now on our live site.
  • 8:41
    Now, one last thing to look at
  • 8:43
    in terms of using this workflow— as I said just a minute ago,
  • 8:47
    the Live database is the canonical database.
  • 8:50
    That's the important one. You don't want to mess with that.
  • 8:53
    So you never move Dev or Test up
  • 8:57
    into the Live database.
  • 8:59
    Only code moves that direction, but quite often,
  • 9:03
    you will want to take the Live database and move it back to Test
  • 9:06
    or to Dev to make sure that those environments
  • 9:08
    are up-to-date so that you can test your code against, essentially, the real site, right?
  • 9:13
    So if we go back to my Dev environment here,
  • 9:16
    and let's say I want to update that, this Workflow tab
  • 9:19
    is going to give me that opportunity.
  • 9:22
    And let's make Clone Database and Files.
  • 9:24
    So I can say I want to take something from either the test environment
  • 9:28
    or the live environment, and I'm going to take it from Live.
  • 9:32
    What I want to take, do I want to run
  • 9:36
    these standard things here?
  • 9:40
    We can go ahead and do that. There's not going to be any harm to that.
  • 9:43
    Update.php, maybe I wouldn't if you already had some code in there.
  • 9:47
    And then this, again, this button tells you what you're going to do.
  • 9:50
    So I'm going to clone database and files from Live
  • 9:52
    into my Development environment.
  • 9:54
    And that's it.
  • 9:57
    So now I have a fresh database and files
  • 10:01
    in my Dev environment, so when I'm writing code,
  • 10:03
    I know that things are working or they're exactly how they're going to be
  • 10:06
    when I get out to the Live site.
  • 10:08
    So those are the basics of the Pantheon workflow.
  • 10:15
    To recap that workflow, we created our Test and Live environments initially
  • 10:20
    from all the initial Dev work we did to launch the site,
  • 10:24
    to get that kind of out there, and in that process,
  • 10:27
    we were cloning the entire environment.
  • 10:30
    So code, database, and files got replicated
  • 10:34
    to all 3 of the environments so they were all in the same starting place
  • 10:37
    with fully functioning websites.
  • 10:39
    After that, we went back and committed some code
  • 10:42
    to my Dev environment and then we went ahead
  • 10:46
    and looked at Test and we merged code from Dev
  • 10:49
    with database from Live into Test, so we basically had all
  • 10:53
    of the latest up-to-date versions of all of the things
  • 10:56
    in one site so we could test that and make sure that it's all working properly.
  • 11:00
    Once we verified that and we looked at the status reports
  • 11:04
    that we could run, then I went ahead and deployed the code out
  • 11:08
    to Live, and our happy little site was clipping along.
  • 11:12
    And then to wrap things up, I also looked at how you can take
  • 11:16
    your Live database and files back down to your Development environment
  • 11:21
    to make sure that's staying up to date as the changes are happening out there.
  • 11:25
    So that is the basic Pantheon workflow and how you can work it.

Use Pantheon Environments


In this tutorial you'll learn how to access and use each Pantheon environment. We'll start by assuming we have done a bunch of work in our initial Dev environment and we're ready to create the Test and Live environments. Once we have all three environments up and running, we'll make some changes to our site code in Dev. With that done we'll merge the code changes in Dev with the Live database in Test so we can make sure everything looks good. We'll also run a site check on Test. Once everything looks clear, we'll deploy the code changes to the Live environment. After deployment we'll see how to pull the Live database back down to our Dev environment whenever we need to.

You can access your code using either SFTP or Git. In this tutorial we'll be using Git. If you'd like to learn more about Git, or get a refresher, you can watch our Introduction to Git Series.

Sponsored by Pantheon

Log in or sign up to download companion files.