Jump to content

Learn PHP 7 now for web programmers


dprogrammer

Recommended Posts

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:

https://philsturgeon.uk/php/2014/07/23/neverending-muppet-debate-of-php-6-v-php-7/https://wiki.php.net/rfc/php6https://news.ycombinator.com/item?id=8786919

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:

Official list of new featuresSuper comprehensive list on GithubWhat to Expect seriesPHP7 at a glanceDigitalOcean’s look at new featuresColin O’dell’s 5 Lesser Known Features, just one in a set of several very useful PHP 7 posts of his

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

Codecourse at https://www.codecourse.com/library/lessons/php-7-new-featuresLaracasts at https://laracasts.com/series/php7-up-and-running

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

http://www.dmiller.io/blog/2015/4/26/comparing-the-php7-and-hack-type-systemshttps://medium.com/the-white-hat-elephpant/php7-more-strict-but-only-if-you-want-it-to-be-78d6690f2090

Getting Started with PHP 7

If you’re not of the VM sort, to install PHP 7 on the most recent version of OS X, see http://php-osx.liip.ch/If you are, however, there’s Jump Start PHP Environment – a book by yours truly, edited and reviewed by the venerable Ross Tuck. It’s a short book on getting started before code – learning about requests, responses, virtual machines, and all the other important server and local development machine setups. The book helps prepare you to write platform-agnostic code, and makes it possible for others to just jump into your team at a whim.Paid intro course from Zend – good for people familiar with PHP 5 who don’t mind shelling out some cashOfficial migration guide from 5.xErika’s excellent post on DigitalOcean

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 pathphp7ize is a code fixer that tries to add PHP 7 features into a PHP 5 codebase automaticallyphp7cc (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 analyzerTuli 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: phpphp:  - 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: falsematrix:  allow_failures:    - php: 7.0before_script:  - travis_retry composer self-update  - travis_retry composer install --no-interaction --prefer-sourcescript:  - phpunit --coverage-text --coverage-clover=coverage.cloverafter_script:  - if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover; fiThe 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 useFor 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 roomTo join a user group for some offline hanging out, check out http://php.ug/
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...