PHP 5.5 First Look
Illustration by Don Barnett

Building a virtual PHP 5.5 development environment


From:

PHP 5.5 First Look

with Jon Peck

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Video: Building a virtual PHP 5.5 development environment

This course is on PHP 5.5, but finding a host or server stack that already has it installed might be difficult, especially in the context that it took almost 4 years from June 2009 to March 2013 for PHP 5.3 to surpass 5.2 as the most installed version. Therefore, I'm going to install PHP 5.5 on a local virtual server from up and running with Linux for PHP developers. All that's needed is to complete the steps from Chapter 3 and Chapter 4. Use of this environment is not required for this course, but it's good to know that there's an option. If you're not interested, just skip forward to Chapter 1. I'm going to be using Virtual Box 4.2.12 from virtualbox.org and Ubuntu Server 12.04.2 long-term support 64-bit from ubuntu.com.
please wait ...
Watch the Online Video Course PHP 5.5 First Look
42m 29s Intermediate Jun 14, 2013

Viewers: in countries Watching now:

Join author Jon Peck as he demonstrates new functionality in PHP 5.5, including generators, the try-catch-finally execution model, and a brand-new password hashing API. A number of existing behaviors, such as the foreach() and empty() functions, have also been updated, and Jon explores what changed and how it can be used. Throughout this course, you'll learn to add new functionality to a simple deck of cards class using these new and updated features, and how to use them for the basis of your own project.

Topics include:
  • Using generators to create simple iterators
  • Dereferencing strings and arrays
  • Enhancing security with the password hashing API
  • Replacing APC with OPcache
  • Normalizing Boolean and unpack() behavior
  • Surveying the removed, incompatible, and deprecated functionality
Subject:
Developer
Software:
PHP
Author:
Jon Peck

Building a virtual PHP 5.5 development environment

This course is on PHP 5.5, but finding a host or server stack that already has it installed might be difficult, especially in the context that it took almost 4 years from June 2009 to March 2013 for PHP 5.3 to surpass 5.2 as the most installed version. Therefore, I'm going to install PHP 5.5 on a local virtual server from up and running with Linux for PHP developers. All that's needed is to complete the steps from Chapter 3 and Chapter 4. Use of this environment is not required for this course, but it's good to know that there's an option. If you're not interested, just skip forward to Chapter 1. I'm going to be using Virtual Box 4.2.12 from virtualbox.org and Ubuntu Server 12.04.2 long-term support 64-bit from ubuntu.com.

To make it easy to install PHP 5.5, I'm going to use phpbrew, which quickly compiles specific versions of PHP. phpbrew can be found at github.com. I'm going to configure Apache to use PHP 5.5 as the default. I'm going to go to a terminal, and then, SSH into my server environment, so for me, it'll be ssh sandbox. The first thing I'm going to do is start an interactive sudo session, which means every commands that I'm going to give will be its root. So I'll type sudo su, it'll ask me for my password, and I'm in. I'm going to install the prerequisites for PHP 5.5, apt-get -y install autoconf automake curl build-essential Libxslt1-dev re2c libxml2-dev, and finally, libmcrypt-dev.

Now that those prerequisites are installed, I'm going to install PHP 5's dependencies. This is different than installing PHP 5, apt-get dash y build-dep php5. This will take a minute or two. Now that the dependencies have been built, I'm going to download phpbrew, which will do the actual compilation.

I'm going to change directory to usr/bin, then I will use the command curl dash space O to download the file from https://raw.github.com/c9s/phpbrew/master/phpbrew. I'll make phpbrew executable, chmod plus x phpbrew. Then, I'll initialize it, phpbrew init. I'm going to specify where versions of php will be installed, echo export PHPBEW_ROOT equals/opt/phpbrew.

I'm going to send that to ~/.phpbrew/init. Then, I'll load the phpbrew configuration by default, echo source ~/.php brew/. I'll send that to i bashrc. I'll load the new configuration, source ~/.bashrc. Now that phpbrew is ready, I'm going to determine all the available versions of PHP 5.5 using phpbrew known space dash dash dsp, and I'll pipe that to grep space dash i php dash 5,5. At the time of this recording, PHP 55.0 Release Candidate 1 is the latest version, so I'll use that for this course.

Now that I know what version is available, I'm going to use phpbrew to install it, phpbrew install php dash 5.5.0rc1, and I'll include the default variants, database, multibyte, m crypt, apache supported, apxs2 equals user bin, apxs2. And then, finally, enable opcache, which I'll demonstrate in a bit. phpbrew will now download the source code of PHP and compile it with the options I've given. Now that PHP 5.5 has been installed, I'm going to use php 5 for this command line session.

phpbrew use php dash 5.5.0rc1. I'm going to configure the date and error log by editing php.ini. nano dash w/opt/phpbrew/php/php-5.5.0rc1/etc/php.ini. I'm going to search for date.timezone, I'm going to set it to America/Los_Angeles and change error_log. And I'm going to set error_log, equal to media sf_sandbox slash php_errors.log. I'll look for session.save path equals, and I'm going to uncomment it. I'm going to search for pdo, mysql.default_socket.

And now that's set to nothing, I'm going to set it to var/run/mysqld/mysqld.sock. I will do the same for the mysql.default_socket, var run/mysqld/mysqld dot.sock and the mysqli.default_socket var run mysqld/mysqld.sock. I'm going to Save, and Exit. I'll reload the Apache configuration to take advantage of the new version of PHP, service apache2 reload.

I'm going to verify from the command line php dash fee. Excellent, it's using PHP 55. And I'm going to check for opcache php dash i grep opcache. It's been installed, but it hasn't been configured yet. I'm going to exit out of the root session and set up phpbrew for my regular user as well, phpbrew init. I'm going to specify where versions of PHP will be installed, which will be echo export PHPBREW_ROOT equals slash opt phpbrew, and I'll send that to phpbrew/init.

I'll load the configuration by default by echoing source phpbrew dash rc, and I'll send that to slash bashrc, and finally I'll source bashrc. That's all the configuration that's needed. I'm going to switch to my browser now and navigate to the web root, http://sandbox.dev:8080. I'll see a status report. The very first one, Database content Exists verifies that it's able to connect to the database.

If not, you'll need to go into the exercise files and edit config.inc.php and make the database configuration changes as needed. Additionally, it will check various php.ini settings including the date.timezone, the mysql.default_sockets, session.save_path, and error_log. I can see that opcache.enable and enable_cli are unset. That's because I haven't explicitly enabled. I will do that later in this course. Click on phpinfo.

I can see that I'm running PHP 5.5, which means the installation was successful. Now that my environment has been configured, let's take a look at what's new in PHP 5.5.

Find answers to the most frequently asked questions about PHP 5.5 First Look .


Expand all | Collapse all
please wait ...
Q: How do I import the php55.sql file into MySQL?
A: Copy the php55.sql file from the Exercise Files folder to somewhere you can access it at the command line. (In this course, that's the 'sandbox' folder.)
 
Then type:
mysql -user=sandbox -password=sandbox sandbox < php55.sql
 
Be sure to substitute your MySQL username and password if necessary.
 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed PHP 5.5 First Look.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.