Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,900 courses, including more Developer and personalized recommendations.Start Your Free Trial Now
- View Offline
- 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
Skill Level Intermediate
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.