Magento 2 + PHP 7.0.5 – Fix Compilation Failures in Production Mode

compilationmagento2php-7

I'm having some issues running the compilation process (either single and multi tenant) with magento 2.0.2~4 running over ubuntu 14.04 & php 7.0.5 (PHP 7.0.5-2+deb.sury.org~trusty+1).

I can run any magento-console process without problem (install/uninstall/upgrade/flush cache etc) but setup:di:compile and setup:di:compile-multi-tenant.

The process finish as usual, no log, no error output, no nothing but after that I can't run the magento-console anymore since the compiler generates an empty serialized string ({}) in var/di/relations.ser then magento can't find the DI definition for Magento\Framework\Filesystem\DriverInterface and throws:

PHP Fatal error:  Uncaught Error: Cannot instantiate interface Magento\Framework\Filesystem\DriverInterface in /var/www/magento2/src/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:73

Any Idea?

Best Answer

Unfortunately this is a known bug with Magento 2 and PHP 7.0.5, you can keep an eye on the issue here: https://github.com/magento/magento2/issues/4070