Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm ignores PHP version setting in project

Tags:

php

ide

phpstorm

I import two different projects to PhpStorm. After that, like always I need to switch PHP version for project from 5.3 to 5.5. After doing this I saved project.

When I reopen this project I see that PhpStorm don't save this setting. I do this same operation again. But again, after reopen project I need to set proper version for project.

I check xml files in .idea folder and php version is there set to 5.5.0 . I check project.default.xml and there php version is set to 5.5.0 too.

I reinstall PhpStorm using JetBrains Toolbox but this doesn't change anything.

My OS is Ubuntu 14.04 . My project files are in my /home folder and user/group of this is www-data/www-data. My user is in group root/www-data/pmucha. There is no problem with edit files (no permission problem).

I use latest version 2017.3.5 of PhpStorm.

I can't find solution to this problem. Can someone help me ?

I'm really tired of setting PHP version every time I open project or start new one.

like image 373
Piotr Mucha Avatar asked Mar 14 '18 08:03

Piotr Mucha


1 Answers

Do you have composer.json in these projects? Most likely yes.

Thing is: PhpStorm by default synchronizes some settings from composer.json file. It can sync your PHP Language Level as well as Source & Test roots.

Right now it looks like PHP version defined in composer.json is 5.3 or lower (5.3 is the lowest in PhpStorm) .. so PhpStorm resets your manually configured version to the provided one by composer.json. Such sync usually happens on project opening .. hence the feeling that IDE does not remember the settings.

https://blog.jetbrains.com/phpstorm/2017/07/configuring-with-composer-in-phpstorm-2017-2/

Two possible solutions:

  1. Either put a proper minimal PHP version into your composer.json (if you are writing your code using PHP 5.5 features .. so what's the point stating the 5.3 as lowest supported -- such code will fail if run using 5.3).

    For example (small part of composer.json):

    "require": {
        "php": ">=5.5",
        ...
    }
    
  2. Or disable such synchronisation at Settings/Preferences | Languages & Frameworks | PHP | Composer --> Synchronize IDE settings with composer.json

enter image description here

like image 194
LazyOne Avatar answered Sep 23 '22 01:09

LazyOne