简体   繁体   中英

Composer: PHP 7 dependency in PHP 5.6 project

I have a PHP 5.6 Nette project (but I think this question includes all php projects with composer) and I would like to add dependency written in PHP 7. Also, PHP for this project is set to 5.6.

Can this work?

Another side question. If I have to give PHP 7 to the project, shouldn't I set PHP to 7 for this project despite the fact, that the project itself is built in PHP 5.6?

Thank you for your answers.

If you bring in PHP7 based deps, youll need to run the whole project on PHP7.

This will likely work fine, but you need to watch out for the compatibility issues between 7 and 5.

There are more than you think, particularly around dereferencing.

Check here for the migration document.

Some dependencies were written in PHP 7 with new features will not work with PHP 5.6.

http://php.net/manual/en/migration70.new-features.php

But when set our project to PHP 7, your project should work. But, as @DevDonkey mentioned, we need to check the compatibility issues between 7 and 5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM