We’re a little bit late to the party but we have some great news for the PHP developers out there: PHP 7 support is now publicly available on Scalingo! From now on, you can execute a PHP 7 application in an instant.
Getting your application executed by the powerful PHP 7 is as simple as specifying it in your Composer file. The important key in this JSON file is require
:
{
"name": "my-php7-app",
"require": {
"php": ">=7.0"
}
}
We use our semver webservice to solve the required version.
If you already have an application running, just update your existing composer.json
file with a newer version. Then, git commit
and git push
this change.
In order to start a PHP 7 application, you first need to write a simple PHP code. For this example, we will just show a simple phpinfo
page. The index.php
file is:
<?php phpinfo();
Then we need to specify the composer.json
. The simplest one would be:
{
"name": "php7-support",
"require": {
"php": ">=7.0"
}
}
Next we must generate the composer.lock
file. We can install composer locally and generate this last file with:
php composer.phar install
Eventually create a Scalingo application, commit and push your files:
scalingo create appname
git remote add scalingo git@scalingo.com:appname.git
git add index.php composer.{json,lock}
git ci -m "Test PHP 7 support"
git push scalingo master
This application is now available online at appname.scalingo.io:
The most awaited change in PHP 7 is the use of the new Zend Engine 3 which provide better performance. Indeed, this new version is twice as fast as the Zend Engine used in PHP 5.6. More performance improvement will be more easily achieved in the future thanks to a better code organization for a migration towards a just-in-time compiler.
Do not be afraid anymore to use the assert
construct when you develop a new code. The new assert has zero cost when in production. More information on thisin the documentation.
PHP now provides a way to specify a type for the return value. Be aware that the behavior changes depending on the strict typing mode you use. More information on this in the documentation.
Support for anonymous classes was added in PHP 7. This simple syntactic sugar add a very convenient way to create simple one-off objects. More information on this in the documentation.
In older PHP versions, handling fatal error use to be nearly impossible. In production, such an error results in a blank screen for the client. In PHP 7, an exception is thrown rather than just stopping the script. Some unrecoverable errors still exist such as out of memory.
To develop this feature, a newThrowable
interface becomes the common ancestor for both Error
and Exception
.
Much more new wonderful things were released in this version such as new operators, easier to use Cryptographically Secure PseudoRandom Number Generator (CSPRNG)… Read the full blog post andchangelog for a comprehensive list of novelties.
The following extensions have been upgraded on the process:
PHP 7 being a recent version, some extensions do not work yet. You should not use this version if you need one of these extensions:
At Scalingo (with our partners) we use trackers on our website.
Some of those are mandatory for the use of our website and can't be refused.
Some others are used to measure our audience as well as to improve our relationship with you or to send you quality content and advertising.