Will it be possible to run symfony 1.4 under PHP7?
If yes, which changes have to be done?
For those, who want to use doctrine 1.2 with symfony 1.4 and PHP7!
In %SF_LIB_DIR%/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Collection.php line 463 you will find:
$record->$relation['alias'] = $this->reference;
In PHP 5 this was interpreted as
$record->${relation['alias']} = $this->reference;
what the author intended. In PHP7 it will be interpreted as
${record->$relation}['alias'] = $this->reference;
what leads to the error regarding relations.
To remedy this problem, just make the implicit explicit:
$record->{$relation['alias']} = $this->reference;
and this problem is gone.
Additionally you have to change in following Doctrine files: Doctrine/Adapter/Statement/Oracle.php line 586 from
$query = preg_replace("/(\?)/e", '":oci_b_var_". $bind_index++' , $query);
to
$query = preg_replace_callback("/(\?)/", function () use (&$bind_index) { return ":oci_b_var_".$bind_index++; }, $query);
Doctrine/Connection/Mssql.php line 264 from
$tokens[$i] = trim(preg_replace('/##(\d+)##/e', "\$chunks[\\1]", $tokens[$i]));
to
$tokens[$i] = trim(preg_replace_callback('/##(\d+)##/',function ($m) use($chunks) { return $chunks[(int) $m[1]]; }, $tokens[$i] ));
and line 415 from
$query = preg_replace('/##(\d+)##/e', $replacement, $query);
to
$query = preg_replace_callback('/##(\d+)##/', function($m) use ($value) { return is_null($value) ? 'NULL' : $this->quote($params[(int) $m[1]]); }, $query);
for PHP7 has no preg modifier 'e' anymore. With those modifications, doctrine 1.2 will continue to work with PHP7 and is working with PHP5 too!
Check out this question which is related to your problem: Symfony 1.4 using deprecated functions in php 5.5
Depending on your code base I think your best option is to upgrade to Symfony 2 or 3. Or you could use this project which supports 5.6 (maybe 7 in the future?): https://github.com/LExpress/symfony1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With