Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving dev desktop settings.php compatibility. #37

Merged
merged 4 commits into from
May 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/phing/build.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bolt:
new.dir: ${bolt.root}/../${project.acquia_subname}
new.dir: ${bolt.root}/../${project.machine_name}
8 changes: 0 additions & 8 deletions template/build/core/phing/tasks/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,4 @@

<!-- Extracts value of $options['uri'] and outputs to local_url property in Phing. -->
<phpVariable file="${repo.root}/drush/drushrc.php" variable="options[uri]" outputProperty="local_url" />
<!-- Extracts values from the $databases array and outputs to db.* properties. -->
<phpVariable file="${local.settings.file}" variable="databases[default][default][database]" outputProperty="db.database" />
<phpVariable file="${local.settings.file}" variable="databases[default][default][username]" outputProperty="db.username" />
<phpVariable file="${local.settings.file}" variable="databases[default][default][password]" outputProperty="db.password" />
<phpVariable file="${local.settings.file}" variable="databases[default][default][host]" outputProperty="db.host" />
<phpVariable file="${local.settings.file}" variable="databases[default][default][port]" outputProperty="db.port" />

<echo>Using "${db.database}" database</echo>
</project>
2 changes: 1 addition & 1 deletion template/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "acquia/${project.acquia_subname}",
"name": "acquia/${project.machine_name}",
"license": "proprietary",
"type": "project",
"repositories": [
Expand Down
9 changes: 7 additions & 2 deletions template/docroot/sites/default/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@
*
* Keep this code block at the end of this file to take full effect.
*/
if ($is_local_env && file_exists(DRUPAL_ROOT . '/sites/default/settings/local.settings.php')) {
require DRUPAL_ROOT . '/sites/default/settings/local.settings.php';
if ($is_local_env) {
if (isset($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR']) && file_exists($_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_${project.machine_name}_dd.inc')) {
require $_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] . '/loc_${project.machine_name}_dd.inc';
}
elseif (file_exists(DRUPAL_ROOT . '/sites/default/settings/local.settings.php')) {
require DRUPAL_ROOT . '/sites/default/settings/local.settings.php';
}
}
8 changes: 4 additions & 4 deletions template/project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project:
# The acquia_subname value is the machine name of your Github repository.
# This will determine the the directory name of the new repository.
acquia_subname: 'bolted8'
# Everyone: This will determine the the directory name of the new repository.
# Dev Desktop users: this should match your local site name.
machine_name: 'bolted8'
# Used for enforcing correct git commit msg syntax.
prefix: 'BLT'
human_name: 'Bolted 8'
Expand All @@ -25,7 +25,7 @@ git:
drush:
aliases:
# The remote environment from which the database will be pulled.
remote: ${acquia_subname}.test
remote: ${machine_name}.test
# The local environment against which all local drush commands are run.
local: self

Expand Down
21 changes: 17 additions & 4 deletions template/readme/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,29 @@ To use Drupal VM with a Drupal project that is generated with Bolt, first place
To make sure Drush commands work correctly with Drupal VM, inside the new project's `build/custom/phing/build.yml` file, override the `docroot` used for Drush commands with the value:

drush:
root: /var/www/[project_acquia_subname]/docroot
root: /var/www/[project_machine_name]/docroot

Then follow the Quick Start Guide in [Drupal VM's README](https://github.com/geerlingguy/drupal-vm#quick-start-guide), but before you run `vagrant up`, make the following changes to your VM
`config.yml` file:

# Update the hostname to the local development environment hostname.
vagrant_hostname: [project_local_domain]
vagrant_machine_name: [project_acquia_subname]
vagrant_machine_name: [project_machine_name]

# Provide the path to the project root to Vagrant.
vagrant_synced_folders:
# Set the local_path for the first synced folder to `../`.
- local_path: ../
# Set the destination to the Acquia Cloud subscription machine name.
destination: /var/www/[project_acquia_subname]
destination: /var/www/[project_machine_name]
type: nfs

# Set this to `7` for a Drupal 7 site, or `8` for a Drupal 8 site.
drupal_major_version: 8

# Set drupal_core_path to the `destination` in the synced folder
# configuration above, plus `/docroot`.
drupal_core_path: /var/www/[project_acquia_subname]/docroot
drupal_core_path: /var/www/[project_machine_name]/docroot

# Set drupal_domain to the same thing as the `vagrant_hostname` above.
drupal_domain: [project_local_domain]
Expand Down Expand Up @@ -86,6 +86,19 @@ Once you've made these changes and completed the steps in Drupal VM's Quick Star

Add a new site in Dev Desktop by selecting _Import local Drupal site_. Point it at the `docroot` folder inside your new code base. Your `/sites/default/settings.php` file will be modified automatically to include the Dev Desktop database connection information.

### Drush support

In order to use a custom version of Drush with Dev Desktop, you must add the
following lines to ~/.bash_profile:

```
export PATH="/Applications/DevDesktop/mysql/bin:$PATH"
export DEVDESKTOP_DRUPAL_SETTINGS_DIR="$HOME/.acquia/DevDesktop/DrupalSettings"

```

Restart your terminal session after adding these lines.

## Alternative local development environments

For reasons, some teams may prefer to use a different development environment. Drupal VM offers a great deal of flexibility and a uniform configuration for everyone, but sometimes a tool like Acquia Dev Desktop, MAMP/XAMPP, or a different environment (e.g. a bespoke Docker-based dev environment) may be preferable.
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/BoltTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct() {

$this->projectDirectory = realpath(dirname(__FILE__) . '/../../');
$this->config = Yaml::parse(file_get_contents("{$this->projectDirectory}/project.yml"));
$this->new_project_dir = dirname($this->projectDirectory) . '/' . $this->config['project']['acquia_subname'];
$this->new_project_dir = dirname($this->projectDirectory) . '/' . $this->config['project']['machine_name'];
}

/**
Expand All @@ -37,7 +37,7 @@ public function testBoltCreate() {
);
$this->assertFileNotExists($this->new_project_dir . '/build/tasks/bolt.xml');
$this->assertNotContains(
'${project.acquia_subname}',
'${project.machine_name}',
file_get_contents($this->new_project_dir . '/docroot/sites/default/settings.php')
);
$this->assertNotContains(
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/DeployTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct() {

$this->projectDirectory = realpath(dirname(__FILE__) . '/../../');
$this->config = Yaml::parse(file_get_contents("{$this->projectDirectory}/project.yml"));
$this->new_project_dir = dirname($this->projectDirectory) . '/' . $this->config['project']['acquia_subname'];
$this->new_project_dir = dirname($this->projectDirectory) . '/' . $this->config['project']['machine_name'];
$this->deploy_dir = $this->new_project_dir . '/deploy';
}

Expand Down