Thursday, August 28, 2014

Learning PHP

Problem

I have recently taken a new post as Lead QA Automation Engineer. The environment that the developers are writing code is in PHP. So I decided to also use PHP for automation. In this case I can easily get help from the developers. Problem is, I have no experience with php. So I have to start learning.

So first step for me was to set up an environment. First off, I want to give credit to where credit is due. I want to credit Juan Treminio's blog for getting me started. His blog is Setting Up a Debian VM, Step by Step. But I want to update this a little bit as I wanted to use Linux Mint in this experiment.

What you need

For this tutorial, I will be using Oracle Virtual Box. This makes it really easy and inexpensive if you make mistakes. You can also use other virtualization technology out there. I am just more familiar with this one.

Next, you will need a ISO from the Linux Mint website. I suggest you get the latest version. There are several types of iso that you can download. For the sake of this tutorial, I will be using the cinnamon installation image.

Lets Start The Install

So that I don't repeat Juan's blog, just follow his steps on setting up the virtual machine and mounting the iso. After you start your vm the first time, come back here.

  • You will be in the Mint Desktop. You will have to click the "Install Linux Mint" icon on the desktop.


  • Next steps you will be choosing your Language and click Continue.
  • Then the installation will check the system requirements. Just click Continue.
  • Next will be the installation type.  Just choose the default option and click Install Now.
  •  
  • You will choose your timezone and click Continue. Next will be you keyboard layout and click Continue.
  • Next will be to enter your identity.  Your name, computer name, username and password. And click on Continue.
  • This will start the installation of Linux Mint. Go and grab something to eat or drink.
  • After the installation, you will be asked to restart. Just click on the Restart Now.
  • After the VM restarts, you will have to enter your password.
  • At this point it will be a good idea to just run the update.  Click on the shield by the clock on the lower right hand side. Then click on the install updates.

  • Click on Devices and Insert Guest Additions CD image...Then click Run
  
 
Congratulations. Your OS is installed and up to date.

Install services

First off, open up a terminal window. Install some mySql

sudo apt-get install mysql-server mysql-client

Answer Y to any prompts that you will get asked during installations.It will ask you to enter a root password.

Next Install Apache and PHP. You will run the following :

sudo apt-get install apache2 openssl
sudo apt-get install php-pear php5 php5-cli php5-common php5-curl php5-dev php5-intl php5-json php5-mcrypt php5-mysql php5-xcache php5-xdebug libpcre3 libpcre3-dev curl 

You will need to install oauth extension from pecl

sudo pecl install oauth


You need to edit both /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini and add the line to the extension section.

extension=oauth.so

Next stop is to install composer.

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer 

Now you have the basic stuff that you need to run php. With your favorite text editor in linux, create a new file and call it version.php. put in that file . Then in a terminal window run php version.php. Your console should now print information about your php.




Congratulations! You are done setting up the basics. Watch out for the next one.