4th April 2013

Coder Lounge, March 2013

John Ennew
Technical Director

Setting up your Drupal 8 local development setup

Setting up Drupal 8 for local development can be a little taxing for those new to core development. Here are some straightforward tips:

  1. Checkout the main Drupal 8 git repository: git clone --branch 8.x http://git.drupal.org/project/drupal.git
  2. Setup your Drupal 8 site and install it in the normal way
  3. Now run git status and add all changed and new files to a file called .gitignore including the new .gitignore file. Running git status again should show no changes.
  4. Before editing any core files, create a branch and switch to it. We recommend a naming convention of 8.x-[issue-number], for example, to create and switch to a git branch to work on issue 134209 run git checkout -b 8.x-134209. Check you are on this branch by running git branch
  5. Now do all the edits for your new patch. When done, commit everything locally, adding new files with git add new/file and committing everything with git commit -a -m 'Issue #134209: Description of my fix'
  6. You can update your patch branch with git rebase origin/8.x
  7. Create your patch by diff'ing against the master 8.x branch with git diff 8.x > [description]-[issue-number]-[comment-number].patch. Comment-number here is the comment which inspired your patch, omit it if it's the first on an issue.
  8. To switch back to the master branch you can run git checkout 8.x as long as there are no uncommitted changes floating about in your patch branch all will be fine.
  9. Update your master branch with git pull origin 8.x and git fetch and then run any db updates via update.php (or rerun install.php to ensure a clean db)
  10. You are back on the lastest Drupal 8 master branch, congratulations, you can now work on your next patch masterpiece. Start by making a new branch: git checkout -b 8.x-[issue-number].

Patch bingo

Reviewing patches is an excellent way to get into Drupal community development. It allows you to get involved with an issue and test work in progress code which allows you to investigate a small portion of the Drupal ecosystem. Patch Bingo is a game on the Drupal website which will pick a random patch or issue which needs some review or input which you can get involved with. Find the links on your dashboard after logging into Drupal.org.

Election Module

We've also been experimenting with the Election module. It allows users to create elections, formed of positions, candidates and votes, with a wide array of configuration options. We are particularly interested in the Single Transferable Votes (STV) type, but a referendum type also comes packaged with the module and there are other voting systems available. Once your STV election is configured, and your candidates voted for, the data can be delivered via the Election Droop Module to the (Python) STV counting framework, which in turn has a multitude of ways to identify the winner, and the result (including working out) is returned to the Election module via Droop. The navigation is a little confusing and we expect users to need a bit of coaching to get familiar with the module. We are creating an custom module to override some of the form options we're happy to use defaults for, which has reduced some of the complexity. Given the sheer complexity of the task at hand, we won't begrudge a few extra clicks here and there.