[size=12pt]Getting started with PHP[/size]
I will assume you are running windows. Run the commands shown in code blocks in the Cmder terminal.
PHP is a server side language, so it needs some server functionality for it to work. This can either be done by
Installing a web server and PHP (and optionally mysql etc) manually on your machine. This is not recommended as you’ll spend too long installing/configuring stuff which really isn’t what you’re after. In addition you are polluting your pc with software and services you don’t really need.
Installing a web server ++ through a bundled / package installer, like XAMPP or WAMPP. Not recommended because of the same issues as above (- some install / config hassle)
Running a virtual machine. This is good as you can have an (swappable) environment that is similar to your hosting environment. You can simply delete the virtual machine at any time and all server stuff is gone. You can also simply change out the VM to another machine, if you want to try to run your app(s) on another OS, PHP version, or similar.
Whatever you choose we will definitly want a better terminal than what’a already available in Windows. If you’re on OSX/Linux you are fine with the built in terminal.
Download/unzip CMDer full http://cmder.net/
Create a shortcut for you where you want to execute it from
The advantage of CMDer, apart from being a proper terminal. Is that you can easily use git, ssh, and other services you will definitly need as a developer.
Set up GIT
GIT is version control software that will allow you to properly handle your (and others) code.
First, you need a key to authenticate with git (could also be used for other services, like ssh)
ssh-keygen -t rsa -b 2048 -C "email@example.com"
Press enter to accept default storage location
Choose a passphrase, you will have to enter this every time you want to use the key. It’s strongly advised to have one as this basically is your identity on the internet.
Register for free account at https://github.com
After registering go to Settings -> SSH keys
Click Add SSH key
Enter any title
Copy the public key you just generated into the key field (notepad c:\Users\Yourname.ssh\id_rsa.pub
Install an IDE
While you can use notepad to code it’s much easier to use a proper editor. IDEs have features like code validation and auto completion which are great to have when working. There are a lot of IDEs available, and when you get the time I suggest you try out a few just to see what works for you. Read more here http://www.phphelp.com/forum/the-occasional-tutorial/make-your-life-simpler-use-an-ide!/
A good and free IDE is Oracle NetBeans (PHP x64 or PHP x86 if you don’t have a 64bit computer)
Getting set up to run virtual machines
Install Virtualbox, the actual virtual machine host
Install Vagrant, a service providing virtual machines and configs that are easy to import to Virtualbox
Creating a directory to hold all our projects
Open up CMDer and you should be in C:\Users\Yourname
Create a directory to hold our projects
note: you can store your projects wherever you want
Enter the projects dir
Setting up a PHP project
We’ll use Scotch Box “- A Vagrant LAMP Stack That Just Works”
Their website says "just clone and run vagrant up, so that’s exactly what we’ll do.
Make sure you are in the projects folder
git clone firstname.lastname@example.org:scotch-io/scotch-box.git learningphp
Enter your key password and the scotch box files should be cloned into projects/learningphp
Enter the project folder
Run the machine
Visit the server in your browser
The file you see there is generated from the index.php file that’s in the public folder. Congratulations, you are now running Ubuntu with PHP, Apache, Mysql, Memcached (and lots of other goodies) in a virtual machine!
Swap out the index.php file with your own file(s), though take note of default mysql credentials
<?php echo 'Hello World!' ?>