Sep 29, 2015 Labs

Getting Ready for PHP7

Getting Ready for PHP7

PHP7 has a release date set: it’s November 12. As always, some of our users will stick to PHP5 for a while before upgrading and others will switch to v7 as soon as it becomes available. To make sure that ActiveCollab is not broken on v7, we started playing with it a bit earlier.

For performance and compatibility testing, we picked the Vagrant VM configured by Rasmus Lerdorf (thanks, awesome work!). You can find it here:

The installation is as easy as running a couple of commands:

  • git clone
  • cd php7dev && vagrant up
  • vagrant ssh

Once in VM, run:

  • makephp 7
  • php -v

The last command will tell you that you're running PHP 7 (currently the exact version number is PHP 7.1.0-dev).

We then downloaded ActiveCollab 5.0.91 and unpacked it to `/var/www/activecollab`. After that, we needed to configure vhost for testing. VM has nginx and PHP-FPM, so we added `/etc/nginx/conf.d/activecollab.conf` with the following settings:

server {
listen 80;
server_name php7talk;
root /var/www/activecollab/public;
index router.php;
access_log /var/log/nginx/activecollab-access.log;
error_log /var/log/nginx/activecollab-error.log debug;

if (!-e $request_filename) {
rewrite ^//assets/(.*)$ //assets/$1 last;
rewrite ^/avatars/(.*)$ /avatars/$1 last;
rewrite ^/wallpapers/(.*)$ /wallpapers/$1 last;
rewrite ^/verify-existence$ /verify.php last;
rewrite ^/proxy.php$ /proxy.php last;
rewrite ^/api/v([0-9]*)/(.*)$ /api.php?path_info=$2&api_version=$1 last;
rewrite ^$ /router.php last;
rewrite ^(.*) /router.php?path_info=$1 last;

include php.conf;

Finally, we added php7dev to `/etc/hosts` on the machine that was running the VM - and we were ready to go.

When we first ran the ActiveCollab installer, it reported a couple of errors.

The first one happened because version_compare() function said PHP 7.0.0-dev is lower than 7.0.0 (being a dev release). We quickly fixed it and discovered that Phar extension was not installed by default. After adding it to the `php.ini` file and restarting PHP-FPM, the installer let us proceed to the next step. The database connection step caused no problems, so we inserted the test credentials and were immediately welcomed by a 500 Internal Server Error.

The first issue was due to code errors in the module model definition that didn't cause any problems in PHP5 but broke down in PHP7\. These were easy to fix, but then we hit the next problem: PHP7 introduces Error class in the global namespace. ActiveCollab has a class with the same name since forever, so we had to move it under the Angie namespace. Once we did the refactoring, the installer successfully installed ActiveCollab and it was smooth sailing from then on.

The key improvement that PHP7 brings over PHP5 is raw performance. The PHP team says in some cases it goes up to 100%. We put it to a test: we made a little script that made ~830 GET requests on a sample data-set and measured how fast it performed with PHP5.6 and PHP7 (same VM, 5 consecutive runs). Here are the results:

While the test is pretty simple and does just one thing (GET requests only, no write to the database, no data cache, only opcode), it proves that PHP7 does perform significantly better than PHP5.6 with operations that the ActiveCollab frontend does most often (reads via API).

This performance boost is “free” - all you need to get it is upgrade your PHP to v7 once the stable release is out.

No application tweaks will be required.

We’ll have a new self-hosted release ready by early next week. That release will pack some interesting new features, stability improvements, as well as experimental PHP7 support for people who are eager to start playing with it - so stay tuned!

Make Real Work Happen!

Start your trial today, free for 14 days! Onboard your team, plan, collaborate, organize your work, and get paid.

By signing up you are agreeing to the ActiveCollab Terms of Service & Privacy Policy.