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

Posted by Jibran Ijaz
Senior Drupal Developer

Dated

Comments

Comment by Bollo

Dated

Very useful. Thank you!

Comment by Anonymous

Dated

Following along at times it too long to work out what was intended

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

Yes that text is missing semicolons and a space after the hyphen should be removed in both cases

Comment by Jibran Ijaz

Dated

Fixed. Thanks for pointing that out.

Comment by Steve Purkiss

Dated

Thanks, this is great! Still getting used to IDEs after years of VIM :D

I've just managed to get it to set up a D8 site on OSX. I hadn't set up PHP or PEAR or anything so once I figured that out it the main issue I had was (and perhaps this just got committed to D8) it's now looking for a services.yml copied from default.services.yml not a settings.php copied from default.settings.php.

Also a little confused as to the install vs reinstall - the reinstall has the commands for creating the files directory and copying the settings.php/services.yml so to set it up I need to do reinstall.

Thanks again,

Steve

Comment by finasteride

Dated

Lerman, it is a great post thanks for writing it!

Comment by Jibran Ijaz

Dated

Thanks for the appreciation.

Comment by dman

Dated

Mostly about OSX + vagrant + phpstorm + vagrant hostsupdater and other plugins...
The tutorial failed for me at the provision-via-phpstorm step because it had "no askpass" and could not mount the /vagrant folder on the guest without admin intervention.
fix here http://apple.stackexchange.com/questions/131385/ssh-askpass-on-mac-os-1…
was necessary for me. Or just doing 'vagrant up' from the cli directly.

Pagination

Add new comment

Restricted HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <h5> <h6>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Not sure where to start? Try typing "hello" or "help" if you get stuck.