PHP
Article

Learn PHP 7, Find out What’s New, and More

By Bruno Skvorc

PHP 7, the next version of the world’s most popular programming language, has been released. We’d love to shoot fireworks and get drunk with our newfound power (seriously, the language is in the true big leagues now, functionality and performance-wise) but we’re sure the rest of the internet will do this for us. Instead, we’ll focus on compiling a (perpetually up to date) list of resources to get started with version 7 – posts describing what’s new, books helping you kick things off, and more. Let’s get to it!

What Happened to PHP 6?

When told the next major version is 7 while we’ve been developing on 5+ so far, many wonder what happened to version 6. It’s a long story, so to avoid looking confused when this is brought up, here are some interesting discussions and posts as required reading:

In short, the unicode problems that were supposed to be solved in version 6 ultimately failed, with too many added complications, and this kind of ruined things for everyone. It was decided that version 6’s rep was too damaged to keep it alive, and a move to PHP 7 was made.

New Features

We’ve spoken about the new features briefly before, but here’s a more comprehensive list of links to information about them – now’s the time to dive in and get ready.

To learn about what’s coming and what an impact it might have on you:

If you’re into video lessons and don’t mind paying for them, two sites covered basically the same thing:

To learn about the type system, arguably the biggest change, and how it compares to hack:

Getting Started with PHP 7

Various compatibility checkers and converters are available:

  • PHP7MAR (Migration Assistant Report) will report any inconsistencies between your current code base and PHP 7, so you can plan and budget your upgrade path
  • php7ize is a code fixer that tries to add PHP 7 features into a PHP 5 codebase automatically
  • php7cc (Compatibility Checker) will try and do the same things as the MAR above – compare their outputs for the most reliable results.

It should be noted that none of the tools above are a replacement for a good test suite – the only way to be 100% certain there’s no bugs left behind is to cover your code with tests so it can be easily inspected and verified during migration.

Last but not least, PHPToday have put together an absolutely fantastic list of talks which you can take a look at here.

Tools, testing and hosting

Lots of helpful tools have already sprung up around the new release:

  • PhpStorm, ahead of the pack as ever, already comes with full PHP 7 mode.

  • Phan is a static analyzer, the features of which you’d best read about here. We’ve got a full tutorial coming up, for the curious.

  • Exakat is another analyzer

  • Tuli is yet another – but development is somewhat halted. If anyone wants to write a comparison post targeting all three, let us know!

  • Andrea Faulds threw out some interesting PHP 7 exclusive packages that warrant a look!

  • A Vagrant box by Rasmus Lerdorf is the box to use when testing on multiple versions of PHP, and can be downloaded here. Tutorial about using it here.

  • Travis CI has supported PHP 7 for a while now. Setting a project up to be 7-tested is easy, just make your .travis.yml file look something like this:

    language: php
    
    php:
      - 5.6
      - 7.0
      - hhvm
    
    # This triggers builds to run on the new TravisCI infrastructure.
    # See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
    sudo: false
    
    matrix:
      allow_failures:
        - php: 7.0
    
    before_script:
      - travis_retry composer self-update
      - travis_retry composer install --no-interaction --prefer-source
    
    script:
      - phpunit --coverage-text --coverage-clover=coverage.clover
    
    after_script:
      - if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover; fi
    

    The above was inspired by the PhpLeague skeleton – a PHP 7 ready skeleton package, so if you’re starting a new one, that’s where to look for a baseline.

  • Right now, the hosting space is rather sparse for PHP 7, but keep an eye on http://phpversions.info/php-7/ – the list will be updated as new information rolls in.

Miscellaneous

For resources on developing extensions for PHP 7 (things are bit different with the extension API), http://gophp7.org/gophp7-ext/ is still the go-to site.

To join communities and discuss things or seek help, some of the following may be of help, in order of popularity:

  • On IRC, the ##php group on freenode will be of use
  • For those in favor of a more static medium, the PHP subreddit can be a place of knowledge, but also a minefield. Tread carefully.
  • If you’re not of the IRC or Reddit kind, but like live discussion nonetheless, there’s the PHP Slack Channel and the StackOverflow PHP chat room
  • To join a user group for some offline hanging out, check out http://php.ug/

Conclusion

Got more resources to share? Let us know! Paid or not, we’ll look at everything you throw at us and potentially include it.

With PHP 7 out, do you intend to convert your apps/packages any time soon? If not, why? Let us know your thoughts and feelings below! And don’t forget – the new version wouldn’t have been possible without the hard work of all the core contributors. They may not always all see eye to eye, but when they pool their resources and run towards a common goal, the sky’s the limit. Here’s to you, champs, thanks for keeping the web epic!

More:
  • Subash Gopalaswamy

    Thats an informative list and only downpoint is not much of own content !. Try to add more of your observations regarding php 7

    • http://www.bitfalls.com/ Bruno Skvorc

      Thanks for the comment! The purpose of the post is, in fact, not to be opinionated but rather a good list of PHP 7 resources – we’ve had proper (both opinionated and practical) looks at PHP 7 before, actually – see http://sitepoint.com/tag/php7

      • Subash Gopalaswamy

        That link is really useful. Lot of information for the latecomers like me. Thanks anyway. Keep up the good work!

  • dawgbone

    I’ve been dreading this day, only because it just rehashes the 6v7 argument that had thankfully quieted down over the last few months.

  • http://www.devgod.in devgodin

    This is really nice article and links which shared @Bruno Skvorc. Thanks for share.

  • Warthog

    Good work. Now I need to know how to easily and safely upgrade my ubuntu server to php 7 from php 5.6

  • Sousa Gaspar

    Dear @brunoskvorc:disqus thank you very much for your excellent article. It helped me to undestand the basis of PHP7. A special thanks for you sharing these links.

  • http://tassedecafe.org Jérémy Heleine

    Wow, thanks for this useful list!

  • http://luke-watts.com/ Luke Watts

    “Most popular programming language in the world”. That’s quite a statement! Don’t get me wrong, PHP is my favorite language but from the stats on Github repos Javascript is the most popular “scripting language” (of which PHP is still classed) with Java and Ruby being the two most popular “programming languages” (languages which can write OS level applications). Then it’s PHP.

    • http://www.bitfalls.com/ Bruno Skvorc

      Fair. Should have been more specific and said “most popular WEB programming language in the world” I guess :)

      • http://luke-watts.com/ Luke Watts

        Yes, I agree completely Bruno…Javascript isn’t a real programming language like PHP *runs away as chairs are thrown and a riot brakes out*

        • http://www.bitfalls.com/ Bruno Skvorc

          JS is most popular in environments like IoT etc, but when you consider actually working web apps that don’t just use a dash of JS to spice up an element or two, I would say that PHP outnumbers it by far.

          • http://luke-watts.com/ Luke Watts

            I dunno…I think Node completely turned things on it’s head. And Angular, React, MongoDB, Firebase etc mean you can make web apps completely in JS now where before you needed PHP, Ruby, .NET, Python etc to handle the DB connections and HTTP Requests and so forth. It will be interesting to see just how fast PHP7 applications will be with HTTP2. That’s gonna be awesome!

  • Wiksiloh

    A big thanks to you for this lovely article…..

  • http://www.bitfalls.com/ Bruno Skvorc

    Why wait for your hosting provider and not use a VPS for max perf?

    • Evert Albers

      Good question. I have a design background, work as independent designer and frontender. I am not confident enough about my skills in setting up web server environments for my clients.

      But you may have a point, with all experience that I have gained in the last few years, I might give it a try now with a ‘not too critical project’ (a photo portfolio site, or something for my band) and see what happens.

      • http://www.bitfalls.com/ Bruno Skvorc

        DigitalOcean have a lot of tutorials you can follow, step by step, with best security practices and everything. Should be straightforward if you’re not afraid of a little command line. If you need 2 months free to check it out, here’s my ref link: http://bit.ly/doref

  • http://www.bitfalls.com/ Bruno Skvorc

    Why wait for your hosting provider and not use a VPS for max perf?

  • Bangali Beta

    Hello Bruno,

    I’m a complete beginner in Php. So that means, I don’t know Php 7 or any of the previous versions.
    Now, I want to start learning Php but from the latest version 7 only.
    So, where can I learn Php 7 as a beginner ? I mean, which online text/video tutorial would teach me Php 7 from the beginning ?
    Most tutorials I find assume I know Php 5 and only mention what’s new in Php 7 and just teach what’s new in Php 7. Those tutorials are no good to me since I don’t know Php 5 or any previous versions. I need a Php 7 tutorial that would teach me starting from the “Hello World!”. I think you know what I mean.
    Not interested in learning Php 5 or any previous versions. Why learn old timers which are about to go extinct. Plus, in Php 7, you write less code and the page loading are twice as faster. Why should I learn old timers where the code would have to be double long resulting in pages loading double slow compared to Php 7 ?

    I do have some programming background but not in Php.

    Anyone have any tutorial suggestions are welcome to reply.

    Thank You

    Ali

  • John Mathew

    Hi Bangali,

    I appreciate your comment about this coding language PHP regardless of version.I have completed free course of PHP at http://goo.gl/Ohh9mQ

    I have heard that PHP developers are getting great package to build website or any software in this language and have great future so i had decided to choose PHP course but i going to register for advance course in it now.

    You comment encouraged me.

    • Bangali Beta

      Thanks Mathew.
      But which version did you learn from that recommended tutorial site of your’s ?

  • Andrew Wyatt

    Thank you! Hit all the points of concern I have approaching to learn PHP

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in PHP, once a week, for free.