Preparing your Applications for PHP 7 with Symfony Polyfills
According to the May 2017 PHP Stats, 53% of PHP developers use PHP 7.0 or 7.1, but only 10% of Composer packages require PHP 7.0 or higher. In fact, 1 in 4 packages still require PHP 5.3, which is used by less than 1% of developers.
Symfony Flex, the new way to create and manage Symfony applications, already requires to have PHP 7.1 installed in your development machines. Symfony 4, to be released in November 2017, will require to have PHP 7.1 in your production servers. Other popular PHP projects have announced similar plans, so if you don't upgrade to PHP 7 soon, you won't be able to install the new versions of the most important PHP projects.
Upgrading your development machines is usually a simple task, but upgrading the rest of the infrastructure (servers, tools, etc.) usually requires more resources. This is where Symfony Polyfills can help you preparing the code of your application for PHP 7.
A polyfill is a PHP 5.3 package that implements functions and features of higher
PHP versions. For example, functions such as
password_*() are only available in PHP 5.5 or higher. However, if you
install the Symfony Polyfill / Php55 package, you can use them in your PHP
$ cd your-project/ $ composer require symfony/polyfill-php55
Symfony Polyfills check if a function exists in your PHP version and if it doesn't exist, it registers a new global PHP function with that name. This means that you can use the latest PHP features in your PHP 5.3 applications and when you finally upgrade them to PHP 7, the code will be already using the latest PHP features.
We have created polyfills for PHP 5.4, 5.5, 5.6, 7.0 and 7.1 and you can use them in any PHP application, not only in Symfony applications. In addition, we've created other polyfills for popular PHP extensions, so you can use those features without actually having installed those extensions: APCu, Mbstring, Iconv, Intl ICU, Intl Grapheme, Intl Normalizer, and XML.
In summary, you have just a few months to upgrade your infrastructure to PHP 7, but you can already start using modern PHP features in your PHP 5.3 applications thanks to the Symfony Polyfills.
Preparing your Applications for PHP 7 with Symfony Polyfills symfony.com/blog/preparing-your-applications-for-php-7-with-symfony-polyfillsTweet this
Become a certified developer! Exams are online and available in all countries.Register Now
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.