Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require PHP 7.1 for Yii 2.1 #11397

Closed
Faryshta opened this issue Apr 21, 2016 · 113 comments
Closed

Require PHP 7.1 for Yii 2.1 #11397

Faryshta opened this issue Apr 21, 2016 · 113 comments

Comments

@Faryshta
Copy link
Contributor

@Faryshta Faryshta commented Apr 21, 2016

Decision

Update to PHP 7.1.

TODO

  • Install APCu via travis instead of APC: #14505
  • Drop memcache (w/o D) support.
  • Use null coalesce: #16270
  • Remove old PHPUnit polyfills: #14506
  • Remove intl polyfills: #16273 (review)

Original issue

Currently only php 5.6, 7 and 7.1 are supported

http://php.net/supported-versions.php

php 5.5 is in security-only support and will reach end of life very soon, while php5.6 will enter security-only support next year. Probably yii 2.1 will take around a year to develop, by that time the entire php5 branch will be obsolete.

Today ubunt 16.04 will be released which includes php7 as the default version and its an LTS so we can expect a lot of server providers to switch to it an offer php7 effortlessly during the next months.

Requiring php7 for yii2.1 can be very useful

  • code generation in gii which can take full advantage of the type hintings.
  • views and controllers can be simplified a lot with the use groups
  • Interally yii2 has many unit tests and has a good dependency injection container, both of them can be benefited by the anonymous classes.
  • Yii security class can benefit a lot of the new random generators.

I propose to make a poll using emoji's. I will post 3 options bellow and any reaction to them (👍 👎 etc) count as a vote for that option. That way someone can vote for more than one option.

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 21, 2016

php 5.5 for minimal version required for yii2.1

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 21, 2016

php 5.6 for minimal version required for yii2.1

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 21, 2016

php 7.0 for minimal version required for yii2.1

@mdmunir
Copy link
Contributor

@mdmunir mdmunir commented Apr 21, 2016

Its depend on when 2.1 stable version released. I am pessimistic it can be done in early next year :D.
depend on what default php version of debian and CentOS.

@samdark
Copy link
Member

@samdark samdark commented Apr 21, 2016

Ubuntu LTS this summer is going to ship PHP 7 by default.

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 21, 2016

@samdark actually it just got released today http://releases.ubuntu.com/16.04/

@samdark
Copy link
Member

@samdark samdark commented Apr 21, 2016

Oh! Great.

@kavitama
Copy link

@kavitama kavitama commented Apr 22, 2016

I remember when we discussed the 2.0 minimum and at that time we were "cautious" and stick with 5.4 that became obsolete before YII2 was "spread out".
I believe php7 is "the minimum" we can expect to go with and take advantage of speed and new functions that will boost YII

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 22, 2016

thats another very valid point @kavitama.

Yii2 took a while for people to migrate from Yii1 or other frameworks. We need to take into account the time it will take to get it developed + the time it will take to "spread out"

@Sammaye
Copy link

@Sammaye Sammaye commented Apr 22, 2016

TBH since Yii2 is already compatible with PHP7 it is reasonable to say that most code written for Yii2 will only have some oddities (like the use of list()). So the transition time between PHP 5.6 and 7 is very small.

I think this thread is vague for one. As I said Yii2 is PHP7 compat, so what would change by making PHP7 the min version? The only real thing is if Yii2 starts using PHP7 specific stuff such as autoloading of functions in namespaces.

@tunecino
Copy link
Contributor

@tunecino tunecino commented Apr 22, 2016

#7936 should also be considered to not having to drop v2.1 and building a 2.2 when PHP 7.1 or 7.2 is released.

@samdark
Copy link
Member

@samdark samdark commented Apr 22, 2016

2.1 isn't going to be such a huge update that it's impossible to update apps with some code changes. We aren't going to do 1.1 → 2.0 again. It will be 2.0 → 2.1 → 2.2 → ... → 3.0 i.e. incremental breakages.

@cebe
Copy link
Member

@cebe cebe commented Apr 22, 2016

The minimum required version has to be determined by technical requirements. If we find that using features that are in a higher version, we can bump version requirement. If we do not use any of the features, the min version will stay.

That means, if we bump to 5.5 or 5.6, what are the features we are going to use?

I am for 5.6 because it adds some cool things that can improve many parts of the framework, such as ::class notation, ..$args function argument unpacking, yield generators, etc...

But if we bump to php7 that would mean a lot of framework concepts should be thought through from ground up considering the newly available languages features. Imo that is out of scope for a 2.1 but rather something for a 3.0.

@cebe cebe added this to the 2.1.x milestone Apr 22, 2016
@samdark
Copy link
Member

@samdark samdark commented Apr 22, 2016

7.0 is for security features only but it's from "nice to have" category since we're already covered that via other means.

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 22, 2016

PHP7 has a lot of feature we can use.

  • The return type hintings which can be very useful for relations, models, validators, etc.
  • The code generated by Gii can take full advantage of this and generate php7 style code inmediately.
  • Anonymous classes can help a lot with dependency injection, configurations and unitary testing.
  • Use groups can simplify the code generated by gii and it can also be very useful when dealing with controllers, views and assets. For example views with a several widgets from the yii\bootstrap namespace.
  • scalar type hints are very useful for controllers and models, and gii can generate this hints too. For example
use common\models\post\{Post,Category,Comment};

PostController extends Controller
{
    public function actionView(int $id): string
    {
        $model = $this->findModel($id);
        // etc
    }

    public function findModel(int $id): Post
    {
           if (null === ($post = Post::findOne($id))) {
               return $post;
           } else {
               // exception
           }
     }
}

This code is not only easier to read for humans, its also much easier to read for IDE's https://blog.jetbrains.com/phpstorm/2015/11/phpstorm-10-is-released-php-7-support-interactive-debug-console-repl-dataflow-analysis-phpunit-5-support-and-more/

@samdark
Copy link
Member

@samdark samdark commented Apr 22, 2016

The return type hintings which can be very useful for relations, models, validators, etc.

Nope since they do not support nulls.

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 22, 2016

@samdark

public function getOrders(): ActiveQuery
{
    return $this->hasMany(Order::class, ['customer_id' => 'id']);
}

Doesn't need a null case.

@samdark
Copy link
Member

@samdark samdark commented Apr 22, 2016

Yes. I'm talking about findOne() and one() like methods.

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 22, 2016

yup those methods can't take the advantage for return typehints, but those are exceptional cases

@cebe
Copy link
Member

@cebe cebe commented Apr 23, 2016

@Faryshta most of what you say does not require the framework itself to require php7. The framework can be PHP7 aware but still be compatible with php5.6. That means if you want to use php7 typehints in your application code, you are free to do that.

@Razzwan
Copy link
Contributor

@Razzwan Razzwan commented Apr 27, 2016

There will always be people who try to slow down the development. I believe our way to be ahead. That's why I'd like to at least php7.0.

@mikehaertl
Copy link
Contributor

@mikehaertl mikehaertl commented Apr 29, 2016

IMO we should not bump requirements to PHP 7 unless there's really good reason to do so. The only acceptable reason I could think of is a boost in performance. I doubt that there's any PHP7-only feature that would have such a great effect - note I'm only talking about framework code here.

So my vote goes for 5.6 to not lock out too many developers. Yii is a framework and as such should put as few constraints on the developer as possible.

@yyxx9988
Copy link
Contributor

@yyxx9988 yyxx9988 commented Apr 29, 2016

@Sammaye
Copy link

@Sammaye Sammaye commented Apr 29, 2016

Zend 3 is a massive improvement even without using PHP7 features. I mean
PHP can actually work in daemon mode (though still not a good idea)

On 29 April 2016 at 09:29, duruitang notifications@github.com wrote:

PHP 7 is so fast and usable! See
http://www.slideshare.net/laruence/php7-for-its-best-performance
[image: image]
https://cloud.githubusercontent.com/assets/13196890/14911326/536e90d6-0e27-11e6-9f62-c0e66bcd33e3.png
[image: image]
https://cloud.githubusercontent.com/assets/13196890/14911339/63a80c2a-0e27-11e6-8510-ffe3a4145027.png


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#11397 (comment)

@cebe
Copy link
Member

@cebe cebe commented Apr 29, 2016

you can have php7 perfomance without forcing other to use php7, so that is not an argument in the discussion here. of course we support php7, the question is only if we should require it.

@Faryshta
Copy link
Contributor Author

@Faryshta Faryshta commented Apr 29, 2016

@cebe another idea can be to have two branches. 2.1 and 2.7 for example with 2.7 requiring php7 and 2.1 php5.6 and then let composer figure out which one install depending on the server

Like its done here https://paragonie.com/blog/2016/04/go-php-7-our-commitment-maintaining-our-open-source-projects

@cebe
Copy link
Member

@cebe cebe commented Apr 29, 2016

that sounds complicated and confusing.

@tomaszkane
Copy link

@tomaszkane tomaszkane commented Jun 25, 2017

@yacine-harbi ok, but IMHO new frameworks (or new version of frameworks) should use actual technology - not stay behind because some admins can't update PHP version.

@samdark
Copy link
Member

@samdark samdark commented Jun 25, 2017

@yacine-harbi we aren't going to raise requirements for 2.0.x.

@cebe
Copy link
Member

@cebe cebe commented Jun 26, 2017

@yacine-harbi pretty sure 7.1 will soon be available in the debian backports.

@tomaszkane
Copy link

@tomaszkane tomaszkane commented Jun 26, 2017

For now we have https://deb.sury.org/

@jblac
Copy link

@jblac jblac commented Jul 20, 2017

as of right now, 7.x is the only answer here even worth considering. From the security updates, performance boosts alone it's worth the upgrade. Then you bring in options like null coalescence, scalar type hints, generator delegation, throwables just to name a few -- and things that I use extensively in our yii2 application.

Any choice but 7.x is a crime against humanity. php5.6 is past it's acceptable EOL limit, and this is the reason that other frameworks have already made the shift.

@cebe
Copy link
Member

@cebe cebe commented Jul 20, 2017

btw: https://twitter.com/cebe_cc/status/866398230665453568

Which PHP version are you running your #Yii2 applications on? #php #yii

  • 30% PHP 5.x
  • 33% PHP 7.0
  • 36% PHP 7.1
  • 1% HHVM

371 Votes on 21. Mai 2017

@TomasVotruba
Copy link
Contributor

@TomasVotruba TomasVotruba commented Aug 16, 2017

This might help to decide: https://gophp71.org/

@samdark
Copy link
Member

@samdark samdark commented Aug 17, 2017

It's already decided but thanks for the link. Added Yii there: DeprecatedPackages/gophp71.org#3

@TomasVotruba
Copy link
Contributor

@TomasVotruba TomasVotruba commented Aug 17, 2017

@samdark Glad to hear that, thanks for the PR!

@schmunk42
Copy link
Contributor

@schmunk42 schmunk42 commented Sep 7, 2017

The commit 0117459 requires 7.1 - unless reverted, the decision is made 😶

@haohetao
Copy link

@haohetao haohetao commented Dec 28, 2017

php 7.1 for minimal version required for yii2.1

@SamMousa
Copy link
Contributor

@SamMousa SamMousa commented May 8, 2018

I would like to suggest that we up this to "the latest version" at the time 2.1 is released.

Since it is a BC break to up the requirements, I'd rather do it right instead of getting stuck with a version that has limited support by the time we release 2.1...

@tomaszkane
Copy link

@tomaszkane tomaszkane commented May 8, 2018

Hm, 7.1 will be supported to 1 Dec 2019, and 7.2 has no (many) cool features http://php.net/releases/7_2_0.php

@SamMousa
Copy link
Contributor

@SamMousa SamMousa commented May 8, 2018

Isn't that just security support?
Anyway my point is that it might be a while before we release 2.1 why decide now?

@tomaszkane
Copy link

@tomaszkane tomaszkane commented May 8, 2018

Yes and no: http://php.net/supported-versions.php
This is question to core developers, IMHO code is writing now - so now devs uses features from 7.1. Other way, you want to refactor code before release to use enhancements from 7.2?
And it probably better to announced target version now, so people can prepare they hosts to Yii 2.1.

@samdark
Copy link
Member

@samdark samdark commented May 12, 2018

Currently it's coded with 7.1 in mind. We can switch to 7.2 if it will give us any advantages.

@koredalin
Copy link

@koredalin koredalin commented May 13, 2018

When we can wait Yii 2.1?

SilverFire added a commit to SilverFire/yii2 that referenced this issue May 13, 2018
Related to yiisoft#11397
samdark added a commit that referenced this issue May 13, 2018
…sageFormatter::parse()` method were removed

  resulting in performance boost. See UPGRADE for compatibility notes
SilverFire added a commit that referenced this issue May 14, 2018
Added ternary_to_null_coalescing to php-cs-fixer config

Related to #11397
samdark added a commit that referenced this issue May 14, 2018
…sageFormatter::parse()` method were removed resulting in performance boost. See UPGRADE for compatibility notes
@samdark samdark closed this May 14, 2018
lav45 added a commit to lav45/yii2 that referenced this issue May 28, 2018
* 2.1:
  Fixes yiisoft#11397: `yii\i18n\MessageFormatter` polyfills and `yii\i18n\MessageFormatter::parse()` method were removed resulting in performance boost. See UPGRADE for compatibility notes
  Update PageCache.php
  Fixing tests after meging with master
  Use null coalesce operator where possible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.