Acquia provides a plethora of tools and documentation aimed at enabling developers to write and manage scalable and maintainable code. We recommend you start with the following best practices and familiarize yourself with the following tools and concepts.
Good coding hygiene is a broad subject. In our experience, the following recommendations address the most common coding issues we see.
Ensure you understand and adhere to Drupal coding standards documented on Drupal.org’s Coding standards web page. The Coder module can help you conduct internal code reviews against the documented standards.
Changing Drupal’s core files makes your application difficult to maintain because you must keep track of and reapply your changes as you apply security and other updates. Remote Administration does not cover modified core or contributed modules, so Acquia recommends you add any customizations with custom modules or theming files. The process allows the Remote Administration team to add updates, while allowing the client development team to change custom code without any modification loss.
If your application requires Drupal core or contributed module modification, refer to Patching and locking modules for details on how to patch or lock modified modules properly to ensure your application remains compatible with Acquia security updates.
For a more in-depth discussion of why altering Drupal core files can be problematic, see Never hack core.
Consider how your architecture and supporting code will scale. Although we cannot mention everything you should do and everything you should avoid, consider the following questions:
drupal_http_request()
) can hang PHP processes, causing Cloud Platform to
display HTTP 503 status codes
under load. External calls should use either AJAX or a Drush job executed
by cron.cron.php
file using an HTTP request
(also known as Poor man’s cron). Acquia’s documentation describes how to
set up cron for Cloud Platform and for
Site Factory.Acquia’s network tools encode best deployment practices. We give you development, stage, and production environments for building, testing, and deploying your code. Remote Administration customers will also see a Remote Administration environment. You can use remote administration environments in whatever way you choose, or not at all. If you need custom environments, you can contact Acquia support to have the environments set up for you. Depending on how you want to use the remote administration environments, you may need added infrastructure.
Cloud Platform uses the Git version control system to manage your application’s code. Git is an industry standard technology allowing you to manage and track changes to your application’s code. Basic documentation on using Git is available from Resources for learning Git. For using version control on Cloud Platform, note the following tips:
Drush is a command-line tool executing Drupal code without accessing the Drupal web interface. To use Drush with Cloud Platform, you can set up an aliases file to execute commands against your Acquia application locally, or you can SSH into your environment and execute Drush commands anywhere within your application’s docroot directory. Drush aliases are explained in more detail in Using Drush aliases.
If Drush is not functional on your application (for example, errors prevent Drush commands from completing), your application will not receive automated updates through Acquia’s Remote Administration automation services.
The Cloud Platform API allows developers to extend, enhance, and customize Cloud Platform. Some customers use Cloud Platform API to integrate with third-party command-line tools, such as Jenkins, to build automated testing and other QA and acceptance steps into Acquia’s development/stage/production workflow.
The Cloud Platform API has three major components:
The Cloud Platform API is available to all Cloud Platform customers. To get started with the Cloud Platform API, including information about your Cloud API credentials, Drush aliases, and Cloud Platform, see Developing with the Cloud Platform API.
Cloud hooks provide a mechanism for systematically executing scripts in response to certain platform events, such as code deployments. For example, you can set up a script to perform database updates routinely, and do feature reversions whenever new code is pushed to a tag. For more information on how to set up cloud hooks, see Automating with Cloud Hooks.
Cloud Platform uses Varnish® for caching. All Acquia load balancers, whether shared or dedicated, have Varnish running and serving traffic. Certain conditions can prevent Varnish from caching requests:
no-cache
headers.As you consider your caching strategy, keep the following in mind to ensure you are making the best use of Varnish, and Drupal’s own internal caching mechanisms:
Ensure you check your build against Acquia’s list of incompatible modules. A list of those modules is available at Modules and applications incompatible with Cloud Platform Cloud Platform. Acquia recommends catching incompatible modules before a large number of dependencies build upon them.