I presume you’re running php 5.x on an Ubuntu 14.04 machine. If you’re windows based, you can easily install Ubuntu 14.04 as a second operating system.
Remember, a genuine php programmer should know a little bit of Linux programming. It’s extremely easy and user friendly. Install Ubuntu on your system and open the terminal by pressing ‘control+alt+t’. For further association with Linux there are tons of free resources available over the internet.
You’ve opened up your terminal; now type this command on it.
sudo add-apt-repository ppa:ondrej/php
A Personal Package Archive, or PPA, is an Apt repository hosted on Launchpad. PPAs allow third-party developers so that they can build and distribute packages for Ubuntu outside of the official channels. They’re often useful sources of beta software – php 7 is also on the developmental stage and it’s not ready for the production environment.
Ondřej Surý maintains the PHP packages for Debian (Ubuntu uses a Debian version), and offers a PPA for PHP 7.0 on Ubuntu.
As a beginner you may find this concept little bit difficult to follow. But, don’t worry. You’ll get acquainted with it in coming times.
Once the PPA is installed, update your local cache to get the contents with this command.
sudo apt-get update
It’ll take some time to update and ask for more space to install php 7 packages. Once it’s done, you can check your php version with a simple command.
It’ll give a nice output that will confirm that you have php 7 installed on your system.
PHP 7.0.10-2+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.10-2+deb.sury.org~trusty+1, Copyright (c) 1999-2016, by Zend Technologies
You have php 7. Now you can keep your php code anywhere in your machine. For local development you may place your codes in ‘/var/www/html’ folder. But it’s not mandatory that you should always keep your codes there.
I make a directory in my ‘home’ folder just by issuing a simple command on the terminal.
A ‘Code’ folder has just been generated. Let us create another folder ‘php7book1’ inside it. We are about to create our further php 7 project in this folder so first of all we should check whether our php 7 is working perfectly. To do that, we must run the local server first. Next, we’ll open up our browser and type http://localhost:8000 so that a php info page will be opened up.
How did I do this?
The very first step was, I created an ‘index.php’ page inside ‘php7book1’ folder and I wrote the simple ‘phpinfo()’ function inside it.
//Code/php7book1/index.php <?php echo phpinfo();
To run the local server, we need to issue this command. But you have to stay inside your project folder.
php -S localhost:8000
Once this command has been issued, you can open your browser and type http://localhost:8000. When your local php server is running, the terminal starts giving you these commands.
PHP 7.0.10-2+deb.sury.org~trusty+1 Development Server started at Thu Sep 15 09:40:44 2016
Listening on http://localhost:8000
Document root is /home/hagudu/Code/php7book1
Press Ctrl-C to quit.
[Thu Sep 15 09:41:00 2016] 127.0.0.1:37991 : /
[Thu Sep 15 09:41:01 2016] 127.0.0.1:37992 : /favicon.ico – No such file or directory
Now you’re ready to start your first day. Remember, it’s our mission to complete our journey in seven days. Within that limit we will have a quick recapitulation on php variables, functions, object oriented programming and design patterns. Our final segment includes a looking up to the cool features of php 7.