1

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.

Martin Pohorský
  • 431
  • 3
  • 15

2 Answers2

1

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.

DevDonkey
  • 4,835
  • 2
  • 27
  • 41
  • O.K. I was thinking if composer can fetch PHP as library and sadly it is not. Your answer satisfied me enough and I hope this will help some others thinking the same way as I did. – Martin Pohorský Mar 28 '18 at 10:47
  • naa composer fetches libraries written in PHP, you need the interpreter files for PHP to run them which are compiled in the server context. – DevDonkey Mar 28 '18 at 10:50
1

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.

Khoa TruongDinh
  • 913
  • 1
  • 13
  • 26
  • Yeah. The problem was that some clients don't want to migrate their projects to PHP 7, so sadly I cannot use libraries written in PHP 7. Thank you for your answer, tho. – Martin Pohorský Mar 28 '18 at 10:49