---
title: "Working with code"
date: "2024-02-14T06:18:38+00:00"
summary: "Manage your application's code effectively with Cloud Platform's powerful tools. Learn best practices for repository structure, code management, and deployment across development, staging, and production environments."
image:
type: "page"
url: "/acquia-cloud-platform/working-code"
id: "db2011b7-4ed5-4ff6-876e-d825c434ddb9"
---

The Cloud Platform interface gives you powerful and easy-to-use tools for managing your application’s code in its version control system. Acquia frequently updates the underlying infrastructure of Cloud Platform to ensure a secure and performant runtime for our customers. Unless otherwise communicated, these infrastructure updates to Cloud Platform are applied simultaneously to all customer environments regardless of their stage or status, whether it is in production or non-production. Infrastructure changes undergo Acquia's rigorous testing process to consistently uphold the highest standards of security and availability for customer applications.

Understanding the repository directory structure
------------------------------------------------

For each application, Cloud Platform creates a master branch with the following three folders:

*   `/acquia-utils` - Contains the application code and files for your development area. In the initial configuration, Cloud Platform deploys code from this directory to both your production and staging infrastructure.
*   `/docroot` - Stores the development copy of your Drupal codebase, from which Cloud Platform executes on your infrastructure if you select `master` as the deployment branch.
*   `/library` - Contains the PHP libraries for your application. This directory is in your PHP include path, so you can add PHP extensions here if needed.

Adhering to code management recommendations
-------------------------------------------

Important

Back up your databases before deploying code. This database backup will create a stable and recent rollback point, minimizing data loss, if your code deployment must be reverted.

Develop your code management workflow on the following best practices and requirements to manage 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 Cloud Platform 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.
*   **Deployed branches cannot be deleted.** Ensure that your workflow accounts for Cloud Platform not allowing you to delete branches that are deployed to an environment.

Code deployment best practices in Cloud Next
--------------------------------------------

Before deploying your code in the Cloud Next environment, follow these best practices:

*   Ensure that your deployment takes advantage of Cloud hooks.
*   Deploy your code only if continuous integration (CI) and associated validation and testing has passed.
*   Sync your production database to a lower environment and then deploy a code to that environment. Do not deploy a code to your production environment without syncing to a lower environment first.
*   Use [Cloud Actions](/acquia-cloud-platform/manage-apps/cloud-actions) to automate common DevOps tasks when code is deployed to an environment.
*   Align release notes or version reports in issue tracking systems, such as Jira, with Git tags for easy review of what was released in a given deployment.
*   Group changes locally and test small iterations when deploying from a dev or stage environment. You can reduce the number of code deployments that are required.
*   Have smaller code bases as that results in faster deployment times. Having a smaller Git repository results in enhanced deployment times and improves scalability of your application. Acquia recommends that the size of your code base is kept under 1 GB.

Note

Code deployment in Cloud Next can take a maximum of 1 hour. Environments on Cloud Next may intermittently experience code deployment times taking more than 5 minutes. Ensure that you close your SSH session before starting your code deployment. If you are in an SSH session and start code deployment, the process might fail. For information about the difference in code updates in Cloud Classic and Cloud Next, visit [How are Atomic code updates different from traditional code deployments?](/acquia-cloud-platform/help/60916-how-are-atomic-code-updates-different-traditional-code-deployments "How are atomic code updates different from traditional code deployments?")

Based on your environment, follow these additional best practices:

### Development

*   Deploy on the baseline develop branch of your development environment frequently, if not daily.
*   Remember that the develop database is not permanent and any content created in this database might be deleted.
*   Conduct QA in the develop branch.
*   Enable the develop modules, such as [DBLog](https://www.drupal.org/documentation/modules/dblog), with environment split. This might be required for development purposes.
*   Do not use the develop database when you pull down a database locally.

### Staging

*   Ensure that deployments happen weekly with tagged releases.
*   Remember that the stage database is not permanent and any content created in this database might be deleted.
*   Conduct User Acceptance Testing (UAT) in the staging environment.
*   Disable the develop modules, such as [DBLog](https://www.drupal.org/documentation/modules/dblog), for this environment.
*   Keep the staging and production database in sync.

### Production

*   Ensure that deployments happen as needed.
*   Remember that the production database is permanent and all content is moved from production to lower environments.
*   Conduct User Acceptance Testing (UAT) after deployments and regression testing.
*   Disable the develop modules, such as [DBLog](https://www.drupal.org/documentation/modules/dblog), for this environment.
*   Enable [production mode](https://docs.acquia.com/acquia-cloud-platform/manage-apps/prod-mode).

Note

*   For information about the difference in code updates in Cloud Classic and Cloud Next, visit [How are Atomic code updates different from traditional code deployments?](/acquia-cloud-platform/help/60916-how-are-atomic-code-updates-different-traditional-code-deployments "How are atomic code updates different from traditional code deployments?").
*   For information about long code deployments in Cloud Next, visit [code deployment](/node/56284#code-deployment).