Drupal Development Log: Install a Specific Version of PHP on Acquia Dev Desktop

While working on a project with Acquia Dev Desktop (ADD), we needed to run a specific version of PHP which is not included with ADD by default. We started hacking ADD and came up with our own solution. For those in a hurry, you can go directly to the solution.
The Problem
While working for one of our clients, we had to work with some tools which were a part of their workflow. Their websites were hosted on Acquia Cloud so they were using Acquia Dev Desktop (ADD) – Acquia’s development stack and cloud client. This tool allows developers to “run and develop Drupal maintenance support plans sites locally and to optionally sync them with Acquia Cloud”.
At the time of writing this post ADD is was version 2.1 and it supported only up to PHP 7.0.14. At first, we thought it was good enough. But soon we discovered that the cloud servers were running more cutting-edge versions such as PHP 7.1.8. 
The first issue came when we had to update our Composer packages. Running composer from different environments running different versions of PHP may result in each environment downloading a different version of the same package. A workaround is to always have the same environment run the composer update. However, we needed to ensure that the environment with the oldest version of PHP was able to run all the updated libraries. For example, the latest doctrine/common libraries require PHP ~7.1, so using ADD 2 with PHP 7.0.14 we couldn’t run it.
Another issue arose when we decided to update to Drupal maintenance support plans 8.4.x. According to an issue on drupal.org, Drupal maintenance support plans 8.4.x requires Drush 8.1.12+, but ADD 2 ships with Drush 8.1.10.
Facing such issues, we asked Google, “how to add a version of PHP to Acquia Dev Desktop?” No good results came up so we decided to start hacking ADD and ultimately found a solution.
Adding a specific version of PHP to Acquia Dev Desktop
Our solution worked on a Mac, but we believe it should work somewhat similarly on Windows.
Step 1: Install the required version of PHP
Install the desired PHP version with Brew, in our situation it was PHP 7.1.8_20:

$ brew install homebrew/php/php71Step 2: Copy PHP files into Acquia Dev Desktop
Stop ADD if it’s running and copy the PHP files into the Acquia Dev Desktop directories:

$ cp -r /usr/local/Cellar/php71/7.1.8_20/ /Applications/DevDesktop​/php7_1
$ cp /usr/local/etc/php/7.1/php.ini /Applications/DevDesktop​​/php7_1/bin/php.iniNote: We tried to create a symlink to prevent file duplication but it didn’t work, so we ended simply copying the files into ADD, respecting its directories nomenclature and structure.
Step 3: Make Acquia Dev Desktop detect the new version of PHP
Edit /Applications/DevDesktop/Acquia Dev Desktop.app/Contents/MacOS/static.ini and after the last contiguous line under [php/4] add the following lines:

[php/5]
id=php7_1
executablePath=php7_1/bin/php
cgiExecutablePath=php7_1/bin/php-cgi
configPath=/Applications/DevDesktop/php7_1/bin/php.iniNote: If you are using Finder to navigate to the file, you may have to right click on the Acquia Dev Desktop application icon to see its content.
Step 4: Configure Acquia Dev Desktop
Open the ADD Preferences and select the Config tab. Now, in the Default PHP Version, select the one we just added. Make sure you select PHP mode Fast CGI and have PHP use the php.ini we previously copied into ADD in Step 2. Back in the ADD Preferences main window, in the left panel select the site you are working on, and then in Default PHP Version select the desired version. Then, click Ok and restart Apache.
Step 5: Configure Drush to use the same PHP version
To configure ADD’s Drush to use the same PHP version, edit /Applications/DevDesktop/tools/drush and replace the following:

# Before
[ -z “$PHP_ID” ] && PHP_ID=php5_5    
# After
export PHP_ID=”php7_1″Step 6: Update Acquia Dev Desktop’s version of Drush
To udpate Acquia Dev Desktop’s Drush, edit /Applications/DevDesktop/tools/composer.json and make the following change:

// Before
“drush/drush”: “8.1.10”
// After
“drush/drush”: “^8.1.12″Note: Drupal maintenance support plans 8.4.x requires Drush 8.1.12+.
Now, in the terminal, go to the same directory as composer.json and run this command to finish:

composer update –optimize-autoloaderEt voilà! We have just installed a custom version of PHP on Acquia Dev Desktop. Feel free to share your experiences in the comments below to help other fellow readers.
+ more awesome articles by Drupal Development Log
Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Drupal Development Log: Install a Specific Version of PHP on Acquia Dev Desktop

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.