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
- Download and install Vagrant
- What is Vagrant? Michael's slides on Vagrant!
- http://downloads.vagrantup.com/
- v1.3.5
- Download and install VirtualBox
- Download and import the base OS - CentOS 6.4
- http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box
Use Vagrant to start up a downloaded CentOS 6.4 box on VirtualBox
- Setup before starting up Vagrant
- Create a folder called Vagrant Boxes in your Documents folder
- Create a subfolder inside Vagrant Boxes called CentOS
- Copy the downloaded CentOS .box file into this CentOS folder
- Open your terminal and navigate to this CentOS folder
- Open up your VirtualBox application
- Watch on Youtube at http://www.youtube.com/watch?v=W3Jh_2PrRrE
- Check list of vagrant boxes added
- Type
vagrant box listto see the list of vagrant boxes added to your machine. You may type this in any directory. - Watch on Youtube at http://www.youtube.com/watch?v=D3FjTphahOc
- Type
- Add Vagrant box to list
- Type
vagrant box add CentOS6.4 CentOS-6.4-x86_64-v20130427.box. Basically the command isvagrant box add <box_name> <path to the .box file>. Don't use the same boxname that is already used in your box list. - You should see "Successfully added box 'CentOS6.4' with provider 'virtualbox'!"
- You should see your box when you type
vagrant box list - Watch on Youtube at http://www.youtube.com/watch?v=qyOTAMkPVJ4
- Type
- Create a Vagrant environment
- Type
vagrant init CentOS6.4inside theCentOSfolder. Basically the command isvagrant init <environment_name>. Usually, I use the same as the boxname. - You should see "A
Vagrantfilehas been placed in this directory. You are now ready tovagrant upyour first virtual environment! Please read the comments in the Vagrantfile as well as documentation onvagrantup.comfor more information on using Vagrant." - Watch on Youtube at http://www.youtube.com/watch?v=IYTkPNvWiIk
- Type
- Use Vagrant to open up a VM
- Type
vagrant upin the folder where you created your Vagrant environment - Type
vagrant haltto shutdown the VM - Watch on Youtube at http://www.youtube.com/watch?v=4ddAzjPhUyE
- Type
- SSH to access the VM
- Type
vagrant sshin the folder where you created your Vagrant environment - Type
exitto exit from the VM - Watch on Youtube at http://www.youtube.com/watch?v=ILPJcVGygUA
- Type
- Use VirtualBox to remove the VM (when needed)
- Right click on machine > Remove
- Watch on Youtube at ...
- Remove Vagrant Box from Vagrant List (when needed)
- Type
vagrant box remove CentOS6.4. Basically the command isvagrant box remove <box_name> - Watch on Youtube at ...
- Type
- 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
