PhpStorm ignores PHP version setting in project - php

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.

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:
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",
...
}
Or disable such synchronisation at Settings/Preferences | Languages & Frameworks | PHP | Composer --> Synchronize IDE settings with composer.json

Related

how do you change the php version that your app uses in heroku platform?

I am trying to change the PHP version that my heroku application uses from the default 7.1 to 7.0. When I try to define it in composer.json it is ignored. What do I need to do?
Apart from updating composer file, if your application requires "php": ^5.6.0" or 7.0.32 you need to make sure that, heroku stack that you are using is 'heroku-16' and not 'heroku-18'.
Run heroku stack in CLI to get the info. By default, it is set to 'heroku-18' which is the latest version and uses Ubuntu 18.04 with PHP 7.2 installed.
If it is on 'heroku-18', use command heroku stack:set heroku-16 to toggle.
P.S: PHP versions 5.6 and 7.0 will reach end-of-life at the end of 2018. No bugfixes, including critical security fixes, will be provided by the PHP maintainers after this date. Users are strongly encouraged to update their applications to the latest version of PHP 7.2 at their earliest convenience. For more information on support timelines for PHP releases, refer to the Supported Versions page on the official PHP website.
From Selecting a runtime, you need to use composer.json and specify the PHP version there:
{
"require": {
"php": "^5.6.0"
}
}
In your case, please have:
{
"require": {
"php": "7.0.0"
}
}
You need the right type of version selector. Read https://getcomposer.org/doc/articles/versions.md
In your case, ~7.0.0 allows 7.0.0 or later, but not 7.1.
Remember to update composer.lock after the change, as documented at https://devcenter.heroku.com/articles/php-support#selecting-a-runtime (read that entire section; the orange box there actually answers exactly the question you posted here).
You really should update your code though. Support for PHP 7.0 will end in a few days, and the PHP team will no longer provide updates except for security fixes. See http://php.net/supported-versions.php
Yo dont need to downgrade the heroku stack to 18 or anything, You can just change the required version of PHP in composer.json then run composer update against your project and finally deploy /build it to the cloud

Change PHP Language Library in eclipse Oxygen

Eclipse for PHP Developers
Version: Oxygen Release (4.7.0)
Build id: 20170620-1800
How can I change the PHP Language Library to PHP 7 (see screen below)? The project results from a previous eclipse version which has been imported to Oxygen. On my machine no PHP is installed, I use Xdebug with a Linux VM, the workspace is on a samba share on that VM (runs PHP 7.0 on Apache).
In the preferences I can add PHP paths, but I have no access to the PHP directory on the Linux VM. But when I create a new PHP project in eclipse, I can select a PHP version (including 7.0).
I wonder if it is the only chance to create a new PHP 7.0 project and copy my files over, or is there a way to alter the PHP 5.6 to PHP 7.0?
Edit: based on howlger's answer
Yes, PHP validation solves it.
I was looking under Validation where is no such thing
Right-click on the project folder and choose Properties
In the properties dialog, in PHP > Validation
Enable project specific settings
As PHP Version choose
7.0 (uniform variable syntax, scalar type hint,...) or
7.1 (void return types, class constant visibility,...)
You also might configure installed PHPs: Window > Properties: PHP > Installed PHPs
See also PHP help: PHP Interpreter Properties

PHP version: module version is higher than installed PHP version

I am using eclipse oxygen for php developers, trying to run php project with version 5.6.
Installed php version: 5.6
PHP version in project facets: 5.6
I tried to follow the the below tutorial, however I could not find php -> interpreter in neither project level nor workspace level.
https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.wst.server.ui.doc.user%2Ftopics%2Ftwinstprf.html
How to resolve module(project?) version complaint?
I run in the same problem when I tried to run/debug a PHP project via Run As -> Run On Server.
Since you have not developed in detail your case I will try to present my case such that you might understand what might cause the problem and how to fix it.
So what I did was to choose the Run -> Run As -> Run on Server menu when a wizard-like dialog box was shown. I choose the PHP's Built-in Server, specified a PHP installed executable (like 5.6) then in the next screen ("Modify the resources that are configured on the server") by trying to move my project from the "Available" list to the "Configured" list I've got a notice error like the one you mentioned in the title. In my case the project was configured with PHP 7.1 while the PHP executable chosen in the "Run on Server" dialog box was 5.6, thus the conflict.
So the problem is that your project is defined to be validated by one PHP version while you are trying to run/debug it with another PHP version. What you can do to fix this is one of the following:
either choose a PHP executable for your "Run on Server" session that is compatible with the project's PHP version; this can be done easy right in the "Run on Server" screen .
either configure your PHP project to be validate by the same PHP version as the one you are trying to run/debug your project with; this can be done by right-click the project -> Properties -> PHP -> Validation then choosing the right PHP version
I hope it helps.

Netbeans 8.0.1 PHPUnity Generator

I tryed install phpunit with netbeans and the installation done correctly! But, when a try generate the phpunit class, the follow error occurred: "The referenced parameter '--ansi' is not registered." and the file was not generated.
Anyone have any idea about this?
It happened the same to me. It seems that we were using the old phpunit-skelgen 1.2.1 version. Apparently, NetBeans 8.0.1 assumes you are using the newest version of phpunit-skelgen, that is 2.0.1.
So, you only have to update the phpunit-skelgen version, for example using this: https://phar.phpunit.de/phpunit-skelgen.phar
I copied that file to where I had my previous phpunit-skelgen.bat files: C:\xampp\php. Of course, this may vary according to your OS or your project structure.
After that, configure NetBeans to use the downloaded file instead of the old file. Something around Tools > Options in Netbeans menu.
Hope this helps!

How to install php 5.3 when 5.4 is already installed?

The usual mistake: I developed with the newest PHP version, while server has 5.3 ... and some errors appears.
Now I want to install Php 5.3 too, but Im affraid it would spoil the settings of 5.4, the registry entries, etc.... in other words, I want to be able to choose to start 5.3 or 5.4.... how to do it?
As far as I can recall php doesn't put anything of importance in the registry. The thing
that determines what version of php will be used is your server config (apache?).
I don't have a windows box nearby right now, but what I would investigate is if there are any
environment variables that are set, e.g. to pear directory. If you can't find
anything like that then you should be quite safe and the config of each php should reside
in files in the respective directory.

Categories