Download, install and serve Drupal8 using one command

During past BADCamp sprints I was showing some of the latest DrupalConsole features to Mauricio Dinarte.

I was talking about the site:install command, at that time the command only supported MySQL and Mauricio asked several questions related to our plans and upcoming features, one of his questions was about supporting SQLite.

Few days after Mauricio published a blog post about that experience, you can read that post at Disposable Drupal installations with drush.

Two months later and after some work done by Omar Aguirre the SQLite support is now available and with some time on my hands I decide to provide a similar feature on DrupalConsole. The only missing piece was to start the PHP's built in server.

The server command has born.

This is a simple command that can receive an argument and this is an example how to use it.


# Run using default address argument value 127.0.0.1.8088
$ drupal server

# Passing address argument to use a different port number 
$ drupal server 127.0.0.1:8089

# Running default address argument using --root option to define the Drupal root. 
$ drupal --root=/Users/jmolivas/develop/drupal/sites/drupal8.dev server

Drupal Console server command

 

Putting all the pieces together

Once we have the only missing piece into the project I decided to take advantage of the DrupalConsole built-in feature to automate and execute several command and create this YAML file: ~/.console/chain/quick-start.yml


commands:
  - command: site:new
    arguments:
      site-name: drupal8.dev
      version: 8.0.0
  - command: site:install
    options:
        langcode: en
        db-type: sqlite
        db-file: sites/default/files/.ht.sqlite
        site-name: 'Drupal 8 Quick Start'
        site-mail: admin@example.com
        account-name: admin
        account-mail: admin@example.com
        account-pass: admin
    arguments:
        profile: standard
  - command: server

The previous configuration will execute several commands in this case command that will download Drupal, install it using SQLite and start PHP's built in server you only need to open your browser and point it to 127.0.0.1:8088.

This is how the execution looks like.

Drupal Console chain command quick start

As you can imagine you can take advantage of this to try Drupal 8 quick, use it on sprints, demos and trainings.

You can also make changes on the provided YAML file and add commands to download modules "module:download", install modules "module:install" , import configurations "config:import" and restore your database "database:restore" or any other command provided by DrupalConsole or a custom command by your own module(s).

The server command and the quick-start.yml file will be included on the next release, but if you want to try this feature now you can clone the project for instructions about getting the project you can visit the Getting the project documentation page.