Consider requiring PHP 7 for Yii 2.1?

I know the current plan is for Yii 2.2 to require PHP 7, but i’m wondering if anyone has considered having Yii 2.1 require it as well.

Here’s why I think it would be a good idea:

  • Ubuntu LTS has been shipping with PHP 7 by default since 16.04, which was released in April 2016, so it’s pretty widely available now.

  • PHP 5.6 active support ended on December 31.

  • Many Yii projects won’t have any choice but to run PHP 7, if we want to keep up-to-date with other dependencies. (Twig 2 came on Jan 5 and requires it, PHPUnit is coming out on Feb 3 and requires it, etc.)

  • The sooner Yii can be updated to take advantage of new PHP features like scalar type declarations, the better!

As for Craft CMS, we’re already seeing about 34% of new installs running PHP 7, and we’re still only requiring 5.3. Our upcoming 3.0 release built on Yii 2 will require PHP 7, regardless of what PHP version Yii 2.1 ends up requiring.


Makes sence, cause the Yii 2.1 final won´t be released before late 2017 (I guess).

That´s two years after PHP 7.0 was released!!!

We aren’t really using any of PHP 7 features in the framework itself and it seems there aren’t many which are beneficial for us so there’s no point in strictly requiring PHP 7 except maybe marketing…

Scalar type hints won’t give much for the framework itself. Return type declarations as well. Additionally return type declarations are pretty much unusable before 7.1 because nulls aren’t counted as valid return value so you have to introduce null-objects which is not good for all cases.

I think most than anything else, you as the framework maintainers should push people towards using PHP >= 7, otherwise we will stay stuck with php 5.x for a very long time and this really is a bad thing if coming from people that have something to say in the PHP world.

Well, personally I don’t mind requiring PHP 7.1.

I do not think it is a bad thing to be compatible with a lower version of PHP if it runs fine on 7. The minimum requirement is a technical thing, not a political one, so we would only bump the requirement if Yii technically requires PHP 7 code.

To do this we should rethink a lot of the frameworks concepts based on PHP 7 features to build something that makes sense and not something that has PHP 7 features just for the sake of it.

I will start working actively on Yii 2.1 in April this year, I sadly have no time for it before that. If we find that by using PHP 7 features we can improve the implementation a lot and the whole thing makes sense, we will of course consider bumping the requirement. That is something we’ll see when working on the implementations, not something to decide on upfront.

Is it really a bad thing?

Personally, I couldn’t care less if some people think that using PHP 5.x is great, because it obviously isn’t

The performance gain alone is totally worth it - and because of the performance, most - if not all - hosting companies have made PHP 7 available for their customers.

However, it is Bad Practice to arbitrarily require a version of PHP that Yii does not actually require. Yii shouldn’t engage in politics.

That’s OK with me. If we need some marketing promotion, we could add:

and runs best with the latest version of PHP 7.x. 

That’s actually a very good idea for 2.0 as well.

Added it to docs.

Ah, you did it! It could have been MY PR.


Interestingly, CakePHP 3 is selling itself as a modern PHP 7 framework. ->

It’s interesting, because the minimum requirement is PHP 5.5.9, according to the first page of their book:

As long as Yii 2 is developed with PHP 7 in mind, I think the same can be said about Yii 2.

Saying that Yii 2 is a modern PHP 7 framework is not the same as saying that it requires it. :)

I think it would be good marketing to brand Yii 2 as a modern PHP 7 framework.

That’s a bit too much to my taste.

That’s one of the reasons why I love Yii :)

1 Like