Skip to main content

Vagrant, PHING, core development and automation

At PreviousNext we rely heavily on vagrant for development environments and phing for performing automated tasks to speed up site building and project development. These tools are hugely beneficial in the long run. In this blog we'll have a look at how we as drupal core developers can automate the tedious tasks like site install/ re-install, testing, coding standards validation and enable modules.

by jibran.ijaz /

nick_schuch has created a repo "Vagrant Drupal 8 on github.

To install and use this is very simple. You can either go through the README.md or read further.

Install vagrant (1.3 to 1.5) and Virtualbox (4.3.6). After installing vagrant install vagrant plugins: (all latest version of these will work just fine.)

  • auto-network
  • hostsupdater
  • vbguest

vagrant plugin install vagrant-auto_network vagrant plugin install vagrant- hostsupdater vagrant plugin install vagrant- vbguest

Next step:

git clone git@github.com:nickschuch/vd8.git cd vd8 vagrant up

Or open vd8 directory in phpstorm as a project.

 

Go to Tools → Vagrant → Up

 

 

After the provisioning

git clone --branch 8.0.x http://git.drupal.org/project/drupal.git app phing install

Or in phpstorm VCS → Checkout from Version Control → Git

 

 

  • Git Repository URL: http://git.drupal.org/project/drupal.git
  • Parent Directory: <path to vd8>
  • Directory Name: app

 

After the clone completion select no when PHPStorm will prompt to open app dir as project.

Open build.xml in the editor or select it in the Project tool window, and then choose Add as Phing build file on the context menu of the selection.

 

It'll show you the phing build window and double click on install command.

 

 

After the install open http://d8.dev/ login using username: admin with password: password. You can reinstall drupal using phing reinstall command or by double clicking the reinstall in phing build window.

As you know we can run phpunit using phpstorm but now you can also run simpletests in phpstorm. Use simpletest:enable to enable simpletest module and to test the class use simpletest:class command it'll prompt you for class name or you can use simpletest:group to test specific test group this command will prompt you for group name.

 

 

As a contrib developer it is a real pain to install contrib modules after install or reinstall but now you can automate that process as well without writing new profile. Create a build.properties files in vd8 root. Add following lines to the file

drupal.profile=standard ;Allows you to install different profile i.e. testing and minimal drupal.pass=secret ;Change drupal installation password. modules.enable=true ;Set it to true to enable modules during install or reinstall modules.list=dynamic_entity_reference bideo ;Module's name seprated by space.

 

You can also check the coding standard of your code by using phpcs:dir command. This command will prompt you the directory path you can add path relative to app directory.

If you want to add new command to phing build task please create an issue or submit a PR for vd8 repository. Please leave a comment below to share you experience.

PS: If you are going to use this on ubuntu then please look at https://github.com/nickschuch/vd8/issues/13