Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Detect CLI color support for Windows 10 build 10586#18385

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@mlocati
Copy link
Contributor

Newer Windows 10 versions (builds starting from 10586) offer VT100 color support.
Seehttp://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-(v1511)-Console-Host-Enhancements

QA
Branch?master - Maybe it could be backported to other branches too
Bug fix?maybe 😉 - Do you you consider a bug not having colors on Windows?
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PR

@nicolas-grekas
Copy link
Member

note that the VarDumper component has similar logic that should be patched also

if (DIRECTORY_SEPARATOR ==='\\') {
returnfalse !==getenv('ANSICON') ||'ON' ===getenv('ConEmuANSI') ||'xterm' ===getenv('TERM');
return
defined('PHP_WINDOWS_VERSION_MAJOR')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

AFAIK,PHP_WINDOWS_VERSION_MAJOR goves the version of Windows where PHP was compiled, not the version where it runs

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

AFAIK, PHP_WINDOWS_VERSION_MAJOR goves the version of Windows where PHP was compiled, not the version where it runs

@stof Whoops, you're right!

@stof
Copy link
Member

Do you you consider a bug not having colors on Windows?

not a bugfix IMO (especially given that we can already force it with a CLI flag)

@mlocatimlocati closed thisApr 1, 2016
@mlocatimlocati deleted the use-cli-colors-on-win10 branchApril 1, 2016 06:17
@mlocati
Copy link
ContributorAuthor

AFAIK, PHP_WINDOWS_VERSION_MAJOR goves the version of Windows where PHP was compiled, not the version where it runs

No, it's not true. They aredetermined at runtime.

I diggereda bit into thesePHP_WINDOWS_VERSION_... constants, and the results are quite interesting.

I tested exactly the same PHP executables under these different PCs:

  • Windows 7
    version 6.1 32 bit (build 7601 SP 1)
    output of standardver command in Windows Command Prompt: 6.1.7601
  • Windows 8
    version 6.2 32 bit (build 9200)
    output of standardver command in Windows Command Prompt: 6.2.9200
  • Windows 8.1
    version 6.3 32 bit (build 9600)
    output of standardver command in Windows Command Prompt: 6.3.9600
  • Windows 10
    version 1511 64 bit (build 10586.164)
    output of standardver command in Windows Command Prompt: 10.0.10586

And here's the values of the three constants (concatenated with dots for simplicity) for every PHP version and every PC:

PHP VersionWindows 7Windows 8Windows 8.1Windows 10
5.3.06.1.76016.2.92006.2.92006.2.9200
5.3.16.1.76016.2.92006.2.92006.2.9200
5.3.26.1.76016.2.92006.2.92006.2.9200
5.3.36.1.76016.2.92006.2.92006.2.9200
5.3.46.1.76016.2.92006.2.92006.2.9200
5.3.56.1.76016.2.92006.2.92006.2.9200
5.3.66.1.76016.2.92006.2.92006.2.9200
5.3.76.1.76016.2.92006.2.92006.2.9200
5.3.86.1.76016.2.92006.2.92006.2.9200
5.3.96.1.76016.2.92006.2.92006.2.9200
5.3.106.1.76016.2.92006.2.92006.2.9200
5.3.116.1.76016.2.92006.2.92006.2.9200
5.3.126.1.76016.2.92006.2.92006.2.9200
5.3.136.1.76016.2.92006.2.92006.2.9200
5.3.146.1.76016.2.92006.2.92006.2.9200
5.3.156.1.76016.2.92006.2.92006.2.9200
5.3.166.1.76016.2.92006.2.92006.2.9200
5.3.176.1.76016.2.92006.2.92006.2.9200
5.3.186.1.76016.2.92006.2.92006.2.9200
5.3.196.1.76016.2.92006.2.92006.2.9200
5.3.206.1.76016.2.92006.2.92006.2.9200
5.3.216.1.76016.2.92006.2.92006.2.9200
5.3.226.1.76016.2.92006.2.92006.2.9200
5.3.236.1.76016.2.92006.2.92006.2.9200
5.3.246.1.76016.2.92006.2.92006.2.9200
5.3.256.1.76016.2.92006.2.92006.2.9200
5.3.266.1.76016.2.92006.2.92006.2.9200
5.3.276.1.76016.2.92006.2.92006.2.9200
5.3.286.1.76016.2.92006.2.92006.2.9200
5.3.296.1.76016.2.92006.2.92006.2.9200
5.4.06.1.76016.2.92006.2.92006.2.9200
5.4.16.1.76016.2.92006.2.92006.2.9200
5.4.26.1.76016.2.92006.2.92006.2.9200
5.4.36.1.76016.2.92006.2.92006.2.9200
5.4.46.1.76016.2.92006.2.92006.2.9200
5.4.56.1.76016.2.92006.2.92006.2.9200
5.4.66.1.76016.2.92006.2.92006.2.9200
5.4.76.1.76016.2.92006.2.92006.2.9200
5.4.86.1.76016.2.92006.2.92006.2.9200
5.4.96.1.76016.2.92006.2.92006.2.9200
5.4.106.1.76016.2.92006.2.92006.2.9200
5.4.116.1.76016.2.92006.2.92006.2.9200
5.4.126.1.76016.2.92006.2.92006.2.9200
5.4.136.1.76016.2.92006.2.92006.2.9200
5.4.146.1.76016.2.92006.2.92006.2.9200
5.4.156.1.76016.2.92006.2.92006.2.9200
5.4.166.1.76016.2.92006.2.92006.2.9200
5.4.176.1.76016.2.92006.2.92006.2.9200
5.4.186.1.76016.2.92006.2.92006.2.9200
5.4.196.1.76016.2.92006.2.92006.2.9200
5.4.206.1.76016.2.92006.2.92006.2.9200
5.4.216.1.76016.2.92006.2.92006.2.9200
5.4.226.1.76016.2.92006.2.92006.2.9200
5.4.236.1.76016.2.92006.2.92006.2.9200
5.4.246.1.76016.2.92006.2.92006.2.9200
5.4.256.1.76016.2.92006.2.92006.2.9200
5.4.266.1.76016.2.92006.2.92006.2.9200
5.4.276.1.76016.2.92006.2.92006.2.9200
5.4.286.1.76016.2.92006.2.92006.2.9200
5.4.296.1.76016.2.92006.2.92006.2.9200
5.4.306.1.76016.2.92006.2.92006.2.9200
5.4.316.1.76016.2.92006.2.92006.2.9200
5.4.326.1.76016.2.92006.2.92006.2.9200
5.4.336.1.76016.2.92006.2.92006.2.9200
5.4.346.1.76016.2.92006.2.92006.2.9200
5.4.356.1.76016.2.92006.2.92006.2.9200
5.4.366.1.76016.2.92006.2.92006.2.9200
5.4.376.1.76016.2.92006.2.92006.2.9200
5.4.386.1.76016.2.92006.2.92006.2.9200
5.4.396.1.76016.2.92006.2.92006.2.9200
5.4.406.1.76016.2.92006.2.92006.2.9200
5.4.416.1.76016.2.92006.2.92006.2.9200
5.4.426.1.76016.2.92006.2.92006.2.9200
5.4.436.1.76016.2.92006.2.92006.2.9200
5.4.446.1.76016.2.92006.2.92006.2.9200
5.4.456.1.76016.2.92006.2.92006.2.9200
5.5.06.1.76016.2.92006.2.92006.2.9200
5.5.16.1.76016.2.92006.2.92006.2.9200
5.5.26.1.76016.2.92006.2.92006.2.9200
5.5.36.1.76016.2.92006.2.92006.2.9200
5.5.46.1.76016.2.92006.2.92006.2.9200
5.5.56.1.76016.2.92006.2.92006.2.9200
5.5.66.1.76016.2.92006.2.92006.2.9200
5.5.76.1.76016.2.92006.2.92006.2.9200
5.5.86.1.76016.2.92006.2.92006.2.9200
5.5.96.1.76016.2.92006.2.92006.2.9200
5.5.106.1.76016.2.92006.2.92006.2.9200
5.5.116.1.76016.2.92006.2.92006.2.9200
5.5.126.1.76016.2.92006.2.92006.2.9200
5.5.136.1.76016.2.92006.2.92006.2.9200
5.5.146.1.76016.2.92006.2.92006.2.9200
5.5.156.1.76016.2.92006.2.92006.2.9200
5.5.166.1.76016.2.92006.2.92006.2.9200
5.5.176.1.76016.2.92006.2.92006.2.9200
5.5.186.1.76016.2.92006.2.92006.2.9200
5.5.196.1.76016.2.92006.2.92006.2.9200
5.5.206.1.76016.2.92006.2.92006.2.9200
5.5.216.1.76016.2.92006.2.92006.2.9200
5.5.226.1.76016.2.92006.2.92006.2.9200
5.5.236.1.76016.2.92006.2.92006.2.9200
5.5.246.1.76016.2.92006.2.92006.2.9200
5.5.256.1.76016.2.92006.2.92006.2.9200
5.5.266.1.76016.2.92006.2.92006.2.9200
5.5.276.1.76016.2.92006.3.960010.0.10586
5.5.286.1.76016.2.92006.3.960010.0.10586
5.5.296.1.76016.2.92006.3.960010.0.10586
5.5.306.1.76016.2.92006.3.960010.0.10586
5.5.316.1.76016.2.92006.3.960010.0.10586
5.5.326.1.76016.2.92006.3.960010.0.10586
5.5.336.1.76016.2.92006.3.960010.0.10586
5.5.346.1.76016.2.92006.3.960010.0.10586
5.6.06.1.76016.2.92006.2.92006.2.9200
5.6.16.1.76016.2.92006.2.92006.2.9200
5.6.26.1.76016.2.92006.2.92006.2.9200
5.6.36.1.76016.2.92006.2.92006.2.9200
5.6.46.1.76016.2.92006.2.92006.2.9200
5.6.56.1.76016.2.92006.2.92006.2.9200
5.6.66.1.76016.2.92006.2.92006.2.9200
5.6.76.1.76016.2.92006.2.92006.2.9200
5.6.86.1.76016.2.92006.2.92006.2.9200
5.6.96.1.76016.2.92006.2.92006.2.9200
5.6.106.1.76016.2.92006.2.92006.2.9200
5.6.116.1.76016.2.92006.3.960010.0.10586
5.6.126.1.76016.2.92006.3.960010.0.10586
5.6.136.1.76016.2.92006.3.960010.0.10586
5.6.146.1.76016.2.92006.3.960010.0.10586
5.6.156.1.76016.2.92006.3.960010.0.10586
5.6.166.1.76016.2.92006.3.960010.0.10586
5.6.176.1.76016.2.92006.3.960010.0.10586
5.6.186.1.76016.2.92006.3.960010.0.10586
5.6.196.1.76016.2.92006.3.960010.0.10586
5.6.206.1.76016.2.92006.3.960010.0.10586
7.0.06.1.76016.2.92006.3.960010.0.10586
7.0.16.1.76016.2.92006.3.960010.0.10586
7.0.26.1.76016.2.92006.3.960010.0.10586
7.0.36.1.76016.2.92006.3.960010.0.10586
7.0.46.1.76016.2.92006.3.960010.0.10586
7.0.56.1.76016.2.92006.3.960010.0.10586

For these versions:

  • PHP 5.4
  • PHP 5.5 up to 5.5.26
  • PHP 5.6 up to 5.6.10

the detected Windows version is wrong because ofthis Windows change.

These versions:

  • PHP 5.5 from 5.5.27
  • PHP 5.6 from 5.6.11
  • PHP 7.0

havethis patch, so those versions have a reliable value for the constants.

Given all that, I think that this pull request is still valid, but it will work only for PHP 5.5 >= 5.5.27, PHP 5.6 >= 5.6.11 and PHP 7+ (older versions will continue to work as before).

So,@stof, shall I reopen this PR?

stloyd reacted with thumbs up emoji

@mlocati
Copy link
ContributorAuthor

PS: a more reliable way to determine the exact Windows version would be to useexec('ver'), but:

  • we should check ifexec can be used (likehere)
  • the output ofver is localized, so we'd need to use a regex to catch its result

@stof
Copy link
Member

stof commentedApr 1, 2016

it is fine if the autodetection works fine only in uptodate PHP versions. Not detecting color support won't break the console (it will just fallback to non colored output by default)

@mlocatimlocati restored the use-cli-colors-on-win10 branchApril 1, 2016 14:50
@mlocatimlocati reopened thisApr 1, 2016
@mlocati
Copy link
ContributorAuthor

I updated this PR, adding the Windows 10 detection code toDeprecationErrorHandler andCliDumper too

if ('\\' ===DIRECTORY_SEPARATOR) {
returnfalse !==getenv('ANSICON') ||'ON' ===getenv('ConEmuANSI') ||'xterm' ===getenv('TERM');
return
defined('PHP_WINDOWS_VERSION_MAJOR')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

is this part actually needed ? We already detect windows just before

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We just detected that the directory separator in\... I'm not 100% sure it's only used in Windows (there are more OSs out there than just *nix, Windows and Mac... What about OS2? Others?....)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think we can safely state that only Windows does'\\' === DIRECTORY_SEPARATOR

@nicolas-grekas
Copy link
Member

👍, as a bug fix on 2.3 to me...

@fabpot
Copy link
Member

I don't think it qualifies as a bug fix (and this PR does not apply cleanly on 2.3 as two files did not exist back then). For such a PR, I propose to merge it on master and be done with it.

@nicolas-grekas
Copy link
Member

Thank you@mlocati.

nicolas-grekas added a commit that referenced this pull requestApr 4, 2016
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes#18385).Discussion----------Detect CLI color support for Windows 10 build 10586Newer Windows 10 versions (builds starting from 10586) offer VT100 color support.Seehttp://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-(v1511)-Console-Host-Enhancements| Q             | A| ------------- | ---| Branch?       | master - Maybe it could be backported to other branches too| Bug fix?      | maybe 😉 - Do you you consider a bug not having colors on Windows?| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Commits-------472a7bf Detect CLI color support for Windows 10 build 10586
@fabpotfabpot mentioned this pull requestApr 29, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@mlocati@nicolas-grekas@stof@fabpot@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp