Phpstorm настройка версии php

PhpStorm ignores PHP version setting in project

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.

is it possible that your project have some code deprecated in the target php version (5.5) so it assume that you’ve a 5.3 project?

this is not the problem. I fix all deprecated errors long time ago. Code is ready for 7.x ,but for month or two it will be still in 5.5. I don’t want to switch for 7.x every time i reopen project.

Читайте также:  Slider with css only

Remember that PhpStorm displays the version of the PHP engine detected in the specified folder and the debugger associated with this PHP engine in the php.ini file. So you must have something wrong on there. For more info: jetbrains.com/help/phpstorm/…

Источник

Phpstorm настройка версии php

The page and all the pages under this node are available only when the PHP plugin is enabled. The PHP plugin is bundled with PhpStorm and activated by default. If the plugin is disabled, enable it on the Installed tab of the Settings | Plugins page, as described in Managing plugins.

Use this page to configure PHP development and unit testing support in the project by choosing one of the available PHP interpreters, see Configure local PHP interpreters and Configure remote PHP interpreters.

In this list, specify the PHP functionality scope to get coding assistance for. Each functionality scope is associated with the PHP version that supports this functionality. Currently PHP 5.3 , PHP 5.4 , PHP 5.5 , PHP 5.6 , PHP 7 , PHP 7.1 , PHP 7.2 , PHP 7.3 , PHP 7.4 , PHP 8.0 , PHP 8.1 , and PHP 8.2 levels are supported. See supported PHP versions for details.

No correlation between the PHP version used in the project and the language level is enforced. Although the language version of each interpreter is detected automatically, you can still tell PhpStorm to provide you with coding assistance that corresponds to a different language level. However, if you attempt to use a code construct that is not supported by the specified language level, PhpStorm suggests a Switch to PHP quick-fix.

When you open an existing project, PhpStorm analyzes it for the language features used and sets the appropriate language level automatically.

You can also set the PHP language level directly from the status bar.

The list is inactive when the PHP language version is constrained in composer.json and settings synchronization with composer.json is enabled on the Composer page of the Settings dialog ( Ctrl+Alt+S ).

In this list, choose the PHP interpreter to use in the current project by default. The list contains all the currently configured local and remote PHP interpreters. See Configure local PHP interpreters and Configure remote PHP interpreters for details.

Click this button next to the CLI Interpreter list to create a new PhpStorm-wide PHP installation configuration in the CLI Interpreters dialog that opens.

When you configure a remote interpreter accessible through SFTP, Vagrant, Docker, or WSL this read-only field shows the path mappings retrieved from the corresponding deployment configuration, Vagrantfile , or Dockerfile . These mappings are read-only.

To provide the custom mappings, click next to the field and specify them in the Edit Project Path Mappings dialog that opens:

  • To add a custom mapping, click and specify the path in the project and the corresponding path on the remote runtime environment in the Local Path and Remote Path fields respectively. Type the paths manually or click and select the relevant files or folders in the dialog that opens.
  • To remove a custom mapping, select it in the list and click .

Path mappings cannot be set for project files or folders that are marked as excluded.

Include Path Tab

The area displays the list of configured include paths . Include paths are used for holding third-party code that is used for completion and reference resolution in some functions/methods that use file paths as arguments, for example, require() or include() .

  • Use and to add and remove paths.
  • Use and to reorder the items in the list.
  • Click to sort the paths alphabetically in the ascending order.

PHP Runtime Tab

The area lists the available PHP stubs, which are normal, syntactically correct PHP files containing annotated function, method, and class signatures, constant definitions, and so on. PHP stubs are added to PhpStorm’s internal knowledge to enhance coding assistance for all the Standard PHP Library components as well as for common extensions.

  • Use the checkboxes next to each item to enable/disable the corresponding stub.
  • To load the set of stubs that matches the set of loaded extensions for the currently configured CLI interpreter, click the Sync Extensions with Interpreter button. For details on configuring interpreters, see Configure local PHP interpreters and Configure remote PHP interpreters.

In the Project tool window, the currently loaded stubs are displayed under the External Libraries node.

PHP stubs are open-source, and you can contribute to their development. See the blog post for details.

Advanced Settings Area

If necessary, you can load a set of custom PHP stubs to be used by PhpStorm. Click next to the Default stubs path field and provide the stubs folder location in the dialog that opens. This way, you can load additional PhpStorm stubs as well as override the bundled ones.

PHP stubs are available as a Composer package, and can thus be declared and installed as a dependency for some third-party package. In this case, they are stored under the vendor/jetbrains/phpstorm-stubs folder inside your project.

To prevent conflicts between the Composer package stubs and PhpStorm bundled stubs, do one of the following:

  • To use the Composer package stubs in your project, explicitly provide the path to their location in the Default stubs path field.
  • To use the PhpStorm’s bundled PHP stubs, make sure that the Default stubs path field is cleared and the vendor/jetbrains/phpstorm-stubs folder is excluded from the project.
    • If the Add packages as libraries option is enabled on the PHP | Composer page of the Settings dialog ( Ctrl+Alt+S ), PhpStorm automatically marks the vendor/jetbrains/phpstorm-stubs folder as excluded. By default, the option is enabled.
    • If the Add packages as libraries is disabled, you can exclude the stubs package folder manually. To do this, in the Project view, right-click the vendor/jetbrains/phpstorm-stubs folder and select Mark Directory as | Excluded from the context menu.

    For details in working with Composer in PhpStorm, refer to Composer dependency manager.

    Analysis Tab

    Use this tab to configure the behavior of certain PhpStorm inspections.

    Exception Analysis

    Use this section to configure exception analysis, which alters the behavior of the Unhandled exception , Redundant catch clause , Missing @throws tag(s) , and Redundant @throws tag(s) inspections.

    Use this list to set the desired exception analysis depth level. By default, 1 is selected, in which case PhpStorm reports the unhandled exceptions for the parent method throwing an exception, as well as the methods directly calling it. Selecting larger values allows you to drill down deeper into the calls hierarchy.

    If 0 is selected, the exception analysis is limited to the parent method.

    Values greater than 1 might negatively affect the IDE’s performance.

    Skip calls with constant params

    Select this checkbox to have PhpStorm skip certain method calls in the instance creation expressions during exception analysis:

      Method calls only having strings or constants as parameters are skipped:

    Use this list to specify the exceptions that are treated as unchecked by PhpStorm. Such exceptions are skipped during exception analysis.

    Click this button to add a class to the Unchecked Exceptions list. In the Choose Class dialog that opens, locate the desired class by using the Search by Name tab or the Project tab.

    Click this button to remove a selected class from the Unchecked Exceptions list.

    Custom Format Functions

    Use this section to include your custom string formatting functions into the Format function parameters mismatch inspection analysis scope. This inspection reports the mismatches between format function parameters and specification conversion entries and by default analyzes the usages of the standard PHP printf and sprintf functions.

    Click this button to add a new function record to the custom format functions list. In the Add Custom Format Function… dialog that opens, provide the name of a class method or function and specify the index of the argument where your formatting template resides.

    Click this button to remove a function record from the custom format functions list.

    Click this button to edit the selected function record.

    Include Analysis

    Use this section to define a custom folder the $_SERVER[‘DOCUMENT_ROOT’] expression should resolve to, which alters the behavior of the Unresolved include inspection.

    The specified path will be used in code completion for the functions/methods that use file paths as arguments (for example, require() or include() ). If the path is left blank, code completion will suggest the paths relative to the project root.

    Commonly, this setting should be modified in case the document root folder defined by your web server configuration is different from the PhpStorm project root folder.

    In this field, provide the folder the $_SERVER[‘DOCUMENT_ROOT’] expression should resolve to.

    The default value is blank: the $_SERVER[‘DOCUMENT_ROOT’] expression in this case resolves to the project root folder. To have it resolve to a different folder, type the desired folder path relative to the project root, or click and select the desired folder in the dialog that opens.

    Источник

    How can I set the PHP version in PHPStorm?

    Is it possible to set the PHP version value, say 4.0+ and have PHPStorm highlight functions that wouldn’t work with the oldest version? For example, for PHP4 this should highlight static function etc. I have a PHP installation on my PC but I don’t want to install an older PHP version for every small script I have to produce. Thanks

    Why would it highlight __construct() ? It’s a perfectly valid function identifier in PHP4, it’s just not being called as a constructor.

    static was avaialbe in PHP4 as well IIRC. Try abstract or use of visibility modifiers public , protected , private . Anyway, writing OO code that’s supposed to work under PHP4 as well as PHP5 is a nonsensical task IMO. The object model differs too much between the two.

    9 Answers 9

    So, you mean to highlight all pieces of code that will not work with the PHP version you are writing it in, right? That can be done here:

    Preferences -> Languages & Frameworks > PHP

    PhpStorm -> Preferences (⌘,) -> Languages & Frameworks > PHP

    Or with newer versions of PhpStorm in Windows:

    File -> Settings -> Languages & Frameworks > PHP

    Sample dialogbox for mentioned prefrences

    then select your PHP version, for example, 7.0

    This is very useful when your local system runs PHP 7.0 , for example, but production is running PHP 5.5 .

    That way PhpStorm will warn you which parts will not work in production, show proper hints during writing code according to the selected version, etc.

    Источник

Оцените статью