Skip to content

Instantly share code, notes, and snippets.

@simkimsia
Created November 27, 2013 07:03
Show Gist options
  • Select an option

  • Save simkimsia/7671726 to your computer and use it in GitHub Desktop.

Select an option

Save simkimsia/7671726 to your computer and use it in GitHub Desktop.
the TOC for the nov 27 2013 workshop at hackerspace SG on vagrant + virtualbox + phpunit

TOC for Nov 27 2013 UTC +8 Singapore, Hackerspace SG, Vagrant + VirtualBox + PHPUnit workshop

Windows Users • Putty - SSH Download from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Putty download

Use Vagrant to start up a downloaded CentOS 6.4 box on VirtualBox

  1. Setup before starting up Vagrant
    1. Create a folder called Vagrant Boxes in your Documents folder
    2. Create a subfolder inside Vagrant Boxes called CentOS
    3. Copy the downloaded CentOS .box file into this CentOS folder
    4. Open your terminal and navigate to this CentOS folder
    5. Open up your VirtualBox application
    6. Watch on Youtube at http://www.youtube.com/watch?v=W3Jh_2PrRrE
  2. Check list of vagrant boxes added
    1. Type vagrant box list to see the list of vagrant boxes added to your machine. You may type this in any directory.
    2. Watch on Youtube at http://www.youtube.com/watch?v=D3FjTphahOc
  3. Add Vagrant box to list
    1. Type vagrant box add CentOS6.4 CentOS-6.4-x86_64-v20130427.box. Basically the command is vagrant box add <box_name> <path to the .box file>. Don't use the same boxname that is already used in your box list.
    2. You should see "Successfully added box 'CentOS6.4' with provider 'virtualbox'!"
    3. You should see your box when you type vagrant box list
    4. Watch on Youtube at http://www.youtube.com/watch?v=qyOTAMkPVJ4
  4. Create a Vagrant environment
    1. Type vagrant init CentOS6.4 inside the CentOS folder. Basically the command is vagrant init <environment_name>. Usually, I use the same as the boxname.
    2. You should see "A Vagrantfile has been placed in this directory. You are now ready to vagrant up your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on vagrantup.com for more information on using Vagrant."
    3. Watch on Youtube at http://www.youtube.com/watch?v=IYTkPNvWiIk
  5. Use Vagrant to open up a VM
    1. Type vagrant up in the folder where you created your Vagrant environment
    2. Type vagrant halt to shutdown the VM
    3. Watch on Youtube at http://www.youtube.com/watch?v=4ddAzjPhUyE
  6. SSH to access the VM
    1. Type vagrant ssh in the folder where you created your Vagrant environment
    2. Type exit to exit from the VM
    3. Watch on Youtube at http://www.youtube.com/watch?v=ILPJcVGygUA
  7. Use VirtualBox to remove the VM (when needed)
    1. Right click on machine > Remove
    2. Watch on Youtube at ...
  8. Remove Vagrant Box from Vagrant List (when needed)
    1. Type vagrant box remove CentOS6.4. Basically the command is vagrant box remove <box_name>
    2. Watch on Youtube at ...
  • Vagrant commands:
  • Open terminal
  • vagrant -h --> tells you the possible commands
  • vagrant box add phpdev /path/to/michael/vbox
  • vagrant reload --> when your vbox is already running, but you want to change your settings in your Vagrantfile
  • vagrant halt --> stop the vbox
  • Setup shared folders
  • vagrant up
  • SSH into box
  • vagrant ssh
  • ssh-keygen
  • Public key/private key
  • vagrant ssh-config
  • vagrant reload
  • vagrant halt
  • Install PHP
  	yum install php-devel php-mysql php-gd php-pear php-xml php-pecl-memcache php-soap php-mcrypt php-pecl-xdebug
  • Install Apache
  • Install Composer
  curl -sS https://getcomposer.org/installer | php
  mv composer.phar /usr/local/bin/composer
  • Packagist
  • Lower case names
  • Install PHPUnit
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit
pear install phpunit/PHPUnit_SkeletonGenerator
  • Sample Codes
  • Test folder
  • Write a test
  • Run test runner
  • Test should fail
  • Write the code
  • phpunit.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment