Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WIll it be possible to run symfony 1.4 under PHP7?

Will it be possible to run symfony 1.4 under PHP7?

If yes, which changes have to be done?

like image 308
Stefan Kraus Avatar asked Dec 03 '22 15:12

Stefan Kraus


2 Answers

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!

like image 109
B. Walger Avatar answered Dec 06 '22 09:12

B. Walger


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

like image 23
yeouuu Avatar answered Dec 06 '22 11:12

yeouuu