Getting Ready for PHP7

· · labs

Post image 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 Active Collab 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 Active Collab 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 Active Collab installer, it reported a couple of errors.

php7 installer error 1

​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.

php7 installer error 2

​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. Active Collab 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 Active Collab 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:

php7 performance table

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

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!

Recommend this Article
Related Articles
comments powered by Disqus
We are

Powerful, yet simple project management

Active Collab helps your team stay organized when you outgrow email. But it’s so much more than that — with plenty of neat add-ons, it’s a one-stop solution for all your business needs.

Find out more