can't change php language level macOS , php71 in /opt/local/bin not /usr/bin

Answered

In preferences -> Languages & Frameworks -> PHP I can't change the language level to 7.1 although I've successfully set the CLI interpreter to my installation of php 7.1 in /opt/local/bin

20 comments

I should add , it is stuck on language level 5.6 , my system version of php in /usr/bin/php is version 5.6 , and I installed 7.1 in /opt/local/bin/php

1

Instead of creating project using existing files, I created a new project, this solved the problem.

0

Hi there,

It must be your composer.json and the PHP version that is set there (IDE by default syncs that value from there).

But you still should be able to change it manually ... unless it has been reworked in 2018.1 (since you have not stated what IDE version you use).

https://youtrack.jetbrains.com/issue/WI-39199#comment=27-2702732

5

I had the same issue, but changing the requirement in my composer.json from "php" : ">= 7.0" to ">=7.1" automatically switched to php 7.1

5

I have the same issue on Windows. Since 2018 version, My PHP language level setting is greyed out and I can't change it... Will try to change the composer version.

0

After changing the composer.json php pre-requisite, it loads the php version I want, but still not able to select it manually in the settings...

0

Definitely having this issue with a composer.json of Drupal 8 that does not have a minimum PHP spec in there. Maybe it's not good to lock this setting to any composer.json file because what does composer really know about your environment anyway?

0

>Maybe it's not good to lock this setting to any composer.json file because what does composer really know about your environment anyway?

It knows about your requirements .. and minimal PHP version is one of such requirements.

Just disable such sync with composer.json and you will be controlling appropriate options manually in IDE settings.

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000794610/comments/115000659650

1

I did not have php version specified in composer.json, but setting was stuck at 5.6 nevertheless. Unchecking _Language & Frameworks -> PHP -> Composer -> Synchronize IDE Settings with composer.json_ helped.

14

My composer file specifies "php": ">=7.2.4", however my IDE settings show PHP Language Level: 5.3 and this can't be edited.

There seems to be a bug is reading the correct version from composer.json.

0

@Mark Olive

Everything is possible.

In any case:

  1. What's you IDE version?
  2. Show your composer.json file (where that php version is defined). Maybe you referring to some another option in another place or something
  3. Do you use Settings synchronisation plugin (or alike)?
  4. Anything interesting/related in idea.log? (Help | Show Log in XXX)
0

I could fix this issue.
I only right-clicked in myproject view under External Libraries on PHP Runtime and then click on configure php Runtime where i could change the language level.

10

@Andriy Bazanov

I found the problem.   I had two projects open in my IDE one legacy PHP 5.3 project and one newer PHP 7.2 project.  Both had composer.json files, the IDE uses the composer file from the first project to set the IDE version for both projects.

I closed the old project and just have one open at a time, this has fixed the problem.

0

"I only right-clicked in myproject view under External Libraries on PHP Runtime and then click on configure php Runtime where i could change the language level."

^ This fixed the issue for me

1

"I only right-clicked in myproject view under External Libraries on PHP Runtime and then click on configure php Runtime where i could change the language level."

^ This fixed the issue for me too

0

If composer.json is the reason why this is locked, then the UI of a disabled select list is at issue. Having to google this issue and come to this thread isn't time well spent.

If the select is disabled, tell me why: "Locked by composer.json"

 

Please and thank you.

0

@Daniel Jackson if you have PHP version specified in your composer.json file, PhpStorm will follow it and synchronize the IDE language level with it. If you need to change the language level, fix composer.json or disable "Synchronize IDE settings with composer.json" option in Settings | Languages & Frameworks | PHP | Composer.

0

Lol...

Life/PHPStorm hack... So, what I did?.. :)

1) Remove path to composer.json (Settings > Languages... > PHP > Composer),
2) change your PHP version (Settings > Languages... > PHP),
3) get back to composer.json path field and recover the path (press Redo like CTRL+Z),
4) Save. ;)

2

PhpStorm 2018.2 on Windows 10.

IMO if I specify ">=7.0" in composer.json, that's "greater than or equal to PHP 7.0." The IDE should allow PHP 7.0, 7.1, or 7.2 to be set, particularly if I point it to an executable and it loads the path fine and says 7.2. 

0

>IMO if I specify ">=7.0" in composer.json, that's "greater than or equal to PHP 7.0." The IDE should allow PHP 7.0, 7.1, or 7.2 to be set

Think about it this way: if you choose 7.1 level (for example) and write your code with 7.1+ features (IDE won't complain) .. then if later it will be run on 7.0.x (as per your composer.json -- 7.0 is perfectly valid) it will fail in such place (where 7.1+ features are used).

 

Other than that: feel free to use Issue Tracker

0

Please sign in to leave a comment.