Webinar recap: Avoiding PHP migration hiccups

Thinking about migrating to PHP 7? Today’s guest speaker, Guido Faecke, IT project manager at Swift Transportation, had some advice:

“Just do it … the longer you wait, the more complicated it will be.”

Yesterday’s webinar, the second episode in our Ask the PHP Experts webinar series, included Maurice Kherlakian discussing how to avoiding migration challenges and Guido giving us first-hand knowledge on how his organization made the move to PHP 7.

If you missed it, here’s your recap. If you attended, you might have missed a few nuggets. Either way, it’s worthwhile to share this post with your colleagues interested in PHP migration.

4 ways to make migration easier

  1. A good plan. You’ll need the right strategy, team, support, and timing built into your plan to ensure a successful migration.
  2. The right strategy. In the field, we mainly see two approaches to migration – Cut-over and Strangler. Most often we recommend the Strangler approach, which is a bit of a longer-term migration strategy. It allows you to add new features of the software to your existing software and start refactoring bit by bit. Cut-over is where you set everything up in staging, and then cut everything to production and hope that it works. Both strategies are good, you just need to pick the one that fits your plan.
  3. The right tools. The main thing is to know what pieces of the software have changed or been depreciated. as Also use tools to help you mitigate risks, such as code sniffers, feature toggles, or commercial tools like Zend Server.
  4. Tests!! Tests help identify the issues so that your team can quickly resolve them. And you can use unit tests to catch errors much faster. We were excited to see over half the webinar’s audience were already using unit tests, based on our poll.

4 key take-aways from a successful migration

Here are some quotes from Guido on his team’s successful migration activity.

  • “Simply put, we migrated to PHP 7 for performance.”
  • “Our users tell us, ‘I don’t know what you did but it’s smoother and better than before.'”
  • “In many applications, we already had unit testing in place, so we just ran the full speed and whatever popped up as an error, we refactored or rewrote. In applications, where we didn’t have unit testing, we scanned the source code for deprecated functionality and did a dry-run, especially for the behavior changes.”
  • “Within the development team we definitely write more solid code [as a result of PHP 7].”

Register for the remainder of this webinar series now.

Audience questions

Here are Maurice’s answers to questions from the audience.

Q: Is it possible to simultaneously run PHP 7 and an older version of PHP?

Maurice: Yes, there are a few different ways. The easiest is probably to run the php-fpm variant of PHP for PHP 7 on Linux (it’s fastCGI), which can be used in conjunction with whatever Apache version you are using. You could set up a name-based or IP based Virtual Host, and configure the fpm variant to interpret PHP, whilst keeping the Apache module SAPI for 5.X. There are a few articles that show how to do that online:

This tutorial explains the procedure for NGINX.

On Windows/IIS, you could download all the versions of PHP you’re interested in and set up a module for every version (FastCgiModule), and have multiple sites, for which you select a specific module (which is configured with a specific version of PHP).

Q: Wouldn’t Strangler run up against mutual incompatibilities between PHP 5 and PHP 7?

Maurice: In addition to running a hybrid 5/7 in dev and test as you perform migrations on certain functions (so you can verify that you get the same outcome with both), your goal is to ensure that the code you’re writing can run in both environments. It would have the unfortunate side effect of you not being able to use PHP 7’s new features and constructs, but only for a while. You can use temporary conditionals abstracted in classes/functions, which you would discard when you move to 7, to handle things like inconsistent behavior (like the list($a[],$a[],$a[]) example that I showed).

Q: Are any of the new functions in PHP 7 better than the equivalent old ones?

Maurice: “Better” is a relative word. PHP 7 has a lot of new features, like the spaceship operator (<=>) (threeway compare), and the null coalescing operator, which are more syntactic sugar, and we also have anonymous classes which I frankly haven’t used yet but they look interesting.

Q: Has exception handling changed in PHP 7?

Maurice: Most errors are now exceptions. Exception handling works the same.

Q: You talked about upgrading the app, how do I actually migrate the PHP packages on my server?

Maurice: Assuming they are PHP packages – you can either see if the maintainer did a PHP 7 package. If there is one, great. If not, either implement the changes and the submit a PR, or find another package that does what you need.

Register for the remainder of this webinar series now.

The following two tabs change content below.
    Kara brings together her broad technical marketing experience and innovative project management skills to drive content marketing efforts at Rogue Wave Software.

    About Kara Howson

    Kara brings together her broad technical marketing experience and innovative project management skills to drive content marketing efforts at Rogue Wave Software.