This article is a set of instructions for developing with Drupal 8 on on Codio a cloud based web ide. Codio provide a virtual 'box' from which you can install and run software, it is perfectly capable of running Drupal 8. I will be posting a blog post highlighting the Joys of coding with Codio soon (link will be added). Suffice it to say for now that being able to pick up a little adhoc development and investigation into Drupal 8 (and other software) at any time I have a moment free, from any browser even a light-weight Chromebook in a coffee shop, is a joy :).
The instructions are partly based on this more general Codio blog post about developing with Drupal.
Now you have a choice, you either follow the instructions below (once you have a Codio account) or use the the script I have prepared on github against a new 'empty template' Codio box, sit back and shortly you will have a fresh, bang up to date, fully installed Drupal 8 site to nose around in. Even quicker, I have a public project on Codio.com which you can fork to obtain a Drupal 8 based project of your own almost instantly.
Create a project
- From the Codio Dashboard, create a new Empty template project.
- Open a Terminal window from the Tools->Terminal window
Clone the Drupal 8 code into a branch
Your terminal will have opened up a command line at /home/codio/workspace the workspace directory is where your code needs to be to work well with the web IDE it is already initialised as an empty GIt repository.
Assuming you want to work with the lastest Drupal 8 code.
- Add a remote to the Drupal repository
git remote add drupal8 http://git.drupal.org/project/drupal.git
- Pull the 8.x branch into your project
git fetch drupal8 8.x git checkout 8.x git pull drupal8 8.x
You should now have all the Drupal code in /home/codio/workspace, you can add more remotes and branches as needed, creating a branch locally and merging in changes to Drupal code periodically (under control as sometimes the latest commits can break your code) works well.
Install PHP, Apache and Mysql
You now need to get all these components installed so that Drupal will run. This is very easy with Codio luckily.
parts install php5 php5-apache2 php5-pdo-mysql php5-gd mysql composerwhich automatically installs PHP5, Apache and MySQL and required modules, you don't need composer to run Drupal but we will use it to install Drush later on.
- Let's start up our services with
parts start apache2 mysql
Why not configure an auto-start so you don't have to manually start each time you restart your project. Create a new file called
startup.shin the root of your project and copy and paste the following lines into it
parts stop apache2 mysql parts start apache2 mysql
Setting up MySQL Database
You now need a MySQL database use-able by Drupal.
- Log into the MySQL shell
mysql -u root(by default there is no root password after the install).
- You should now see the '>' prompt. Enter the following
CREATE DATABASE drupal;
- We'll create a user
CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'drupal';
- Now we'll grant that user all privileges
GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost';
- Let's flush privileges
- and exit the MySQL shell by entering
Now check things are running at a basic level before continuing with the rest of the config. From the Preview menu (the rightmost Codio menu) select the dropdown list and click on 'Box URL'.
You should see the Drupal installer open up in a new browser tab. You could now instal Drupal on your box through the web browser (or you can wait until we have installed Drush).
Most Drupal developers are going to want to have Drush on their command-line, the great thing about a Codio box is that once you have the terminal open and have got used to how the box is setup you can do a lot of the things you would on a VPS.
Clone Drush from Github and install dependencies with Composer
cd /home/codio git clone https://github.com/drush-ops/drush cd drush composer install
Make Drush globally available.
cd /home/codio/.parts/bin ln -s /home/codio/drush/drush drush
Now optionally you may install Drupal via the command line.
cd /home/codio/workspace drush -y si standard --db-url=mysql://drupal:drupal@localhost/drupal --site-name=drupal8.codio --account-name=admin --account-pass=admin --firstname.lastname@example.org