Working with code

The Acquia Cloud interface gives you powerful and easy-to-use tools for managing your application's code in its version control system.

Repository directory structure

For each application, Acquia Cloud creates a master branch with three folders: acquia-utils, docroot, and library. The acquia-utils directory contains two files by default, both of which help developers view and manage the logs created by their servers on Acquia Cloud. The docroot directory is for your Drupal codebase that Acquia Cloud executes on your web servers if you select master as the deployment branch. The library directory is in your PHP include path, so you can add PHP extensions here if needed.

     /acquia-utils
     /docroot
     /library

In this directory structure:

  • /acquia-utils - Contains the application code and files for your development area. In the initial configuration, Acquia Cloud deploys code from this directory to both your production and staging servers.
  • /docroot - Stores the development copy of your Drupal codebase.
  • /library - Contains the PHP libraries for your application. This directory is in your PHP include path.

You should follow these best practices in managing code in your version control system and environments:

  • Master is always a stable, up-to-date codebase.

    This means that the master is immediately able to be deployed to production unless updates are in process. The master is deployed to the Dev environment unless testing is in process.

  • Branches are used for developing and testing new code and updates.

    Branches will be taken from the production tag. Acquia labels branches according to the function, the date and time started.

  • Development can happen in parallel on different branches.

    Acquia recommends keeping track of changes that are eventually merged into master and regularly updating the branch with master to ensure that the working branch is up-to-date. This may or may not be possible depending on the type of development on the branch.

  • All tested and approved branches should be merged back into master.

    Once they are fully tested, you should merge development branches into master. This ensures that master always includes updated code.

  • Tags from tested and approved branches (including the master) are used for production.

    Tags are similar to snapshots of the code, frozen in time. The Acquia Cloud interface doesn't allow you to make commits on a tag. By not modifying tags, you can easily go back to a previous tag if an error is discovered on the most recent tag.

Working with code on the Environments page

The Code elements of the Environments page provide a user interface for deploying code from your repository to your application's environments. When you commit a branch to your repository, Acquia Cloud updates the environment running that code branch.

To move your code between environments, drag a Code element from one environment to another environment. Acquia Cloud creates a new tag for the head version of that branch (the most recently committed code version) and then deploys the tag in the environment you selected.

Deploy code by dragging it to another environment

You should make and test changes to administrative configurations, views, and other major application settings only in your Development or Staging environments. Do not make or test changes in your Production environment. If you make a change that breaks your application in the Production environment, you might bring your live application down.

Deploying code

To switch the code deployed in an environment from one tag or branch to another, using the Environments page:

  1. In the Code element for the environment, click the code switch button.

    The Code switch button

  2. In the Switch code dialog, select a tag or branch from the Select branch menu and click Continue.
  3. In the Switch code confirmation dialog, click Switch.

When you select a new branch or tag to deploy, that code is retrieved from your repository and deployed to the appropriate environment on the web servers. The deploy task appears in the Activity task list.

Moving code from one environment to another

To move code from one environment to another:

  1. Check out your repository to your local computer.
  2. Make changes to your application in the /master directory, or whatever branch you've configured to deploy for the Development environment. Any environment deploying a branch will deploy all commits to that branch immediately. This is a good reason never to deploy the master branch on your Production environment; code committed to master would then appear immediately in your live application, before you have had a chance to test and verify it.
  3. Drag your Dev Code element to Stage, and then click Deploy.

    When you drag your Dev code container to the Stage environment, Acquia Cloud creates a symbolic link between the Staging environment and the head version (the most recently committed code version) of trunk in your Development environment. When you click Deploy, Acquia Cloud creates a tag and updates the web server to that version of your code. The default tag format is yyyy‐mm‐dd.version (for example, tags/2016‐09‐18). From the example, the next tag you create would be 2016‐09‐18.0.

    When you have a version that you are ready to deploy to your live production application, drag your code element from the Stage environment to Prod. If the Staging environment is running a tag, that same tag is deployed into Production.

  4. To change the code on your servers, you can:

    • Commit changes to the currently deployed branch.
    • Select a different repository branch or tag to deploy.

Deploying code from the Environment Overview page

You can also deploy code on an environment or copy code from one environment to another using the Overview page of an environment.

Deploying code

To switch the code deployed in an environment from one tag or branch to another, using the Overview page:

  1. On the Environments page, click the name of the environment to open that environment's Overview page.
  2. On the Overview page for the environment, click Switch.

    Click Switch to deploy a different tag or branch

  3. In the Switch code dialog, select a tag or branch from the Select branch menu and click Continue.
  4. In the Switch code confirmation dialog, click Switch.

Copying code from a different environment

To copy code from one environment to another (creating a new tag and deploying it) using the Overview page:

  1. On the Environments page, click the name of the environment to open that environment's Overview page.
  2. On the Overview page for the environment, click Deploy.

    Click Deploy to deploy a tag or branch from a different environment

  3. In the Deploy code dialog, select the environment from which you want to copy a tag or branch, and then click Continue.
  4. In the Deploy code confirmation dialog, optionally enter a commit message that describes the new deployment, and then click Deploy.

Run update.php

When you have release new code to an environment, you may need to execute any pending database updates. You can check for needed database updates by going to http://[site_URL]/update.php in your browser. The update.php page displays whether there are any scheduled database changes. These are common after core or contributed module updates. After applying the changes, update.php will also clear your application's caches. It is a good practice to clear Drupal's caches manually, though, as this will assure you that you are starting from a clean slate. After making sure that Drupal's caches are cleared, you will also need to clear the Varnish cache. Be cautious before clearing caches on a production environment under load.

Reverting code

To revert code to an earlier version:

  1. In the Code element for the environment, click the code switch button.
  2. In the Switch code dialog, select the tag for the version you want to revert to and click Continue.
  3. In the Switch code confirmation dialog, click Switch.

When you deploy a previous branch or tag, Acquia Cloud retrieves the code snapshot from your repository and then deploys it on the appropriate environment on the web servers.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
By submitting this form, you accept the Mollom privacy policy.

Contact supportStill need assistance? Contact Acquia Support