Phpstorm php version change

Как я могу установить версию PHP в PHPStorm?

Можно ли установить значение версии PHP, скажем 4.0+, и иметь функции выделения PHPStorm, которые не будут работать с самой старой версией? Например, для PHP4 это должно выделить static function и т.д. У меня есть установка PHP на моем ПК, но я не хочу устанавливать более старую версию PHP для каждого небольшого script, который я должен создать. Спасибо

Почему он выделил __construct() ? Это совершенно правильный идентификатор функции в PHP4, просто он не вызывается как конструктор.

Статика была доступна в PHP4, а также IIRC. Попробуйте abstract или использовать модификаторы видимости public , protected , private . В любом случае, написание ОО-кода, который должен работать как на PHP4, так и на PHP5, — бессмысленная задача IMO. Объектная модель слишком сильно отличается между ними.

3 ответа

Итак, вы хотите выделить все фрагменты кода, которые не будут работать в версии, которую вы пишете, не так ли? Это можно сделать в:

Preferences -> Languages & Frameworks > PHP 

Или в новых версиях PhpStorm:

File -> Settings -> Languages & Frameworks > PHP 

Изображение 107743

затем выберите свою версию, например, 7.0

Это очень полезно, если ваш локальный пользователь находится в 7.0, например, но в версии 5.5. Таким образом, phpstorm предупредит вас, какие части не будут работать на производстве.

Читайте также:  Html alt для чего

Для текущей версии PhpStorm: PhpStorm 2016.3.2 . Это должен быть File -> Settings -> Languages & Frameworks -> PHP .

что это за скриншот des1roer? Ваши общие настройки? Что делать, если вы перейдете к настройкам PHP, в соответствии с инструкциями?

Изображение 107744

Откройте диалоговое окно «Параметры», выбрав Файл | Настройки, затем нажмите PHP в разделе Языки и рамки. Откроется страница PHP.
теперь вы можете сделать 2 вещи:
1) На открывшейся странице PHP вы можете установить «Уровень языка PHP».
2) Вы можете установить версию PHP, которую вы хотите локально, например, установив пакеты, такие как wamp или xamp, и затем установите интерпретатор вашего PHP. На открывшейся странице PHP. подробнее здесь

Источник

Michael Smith

image

Michael Smith - Full-Stack Web Developer profile photo square

How To Change Current Project PHP Version in PhpStorm 2022.2.2

Today, we’re going to look at a couple of methods for changing the current project’s PHP version in JetBrains PhpStorm 2022.2.2. While this method only applies to the currently opened project in PhpStorm, there is a way to change the default PHP version for new projects.

Take note of the current project’s PHP version by looking at the value in the Status Bar near the bottom right corner of the IDE window.

How To Change Current Project PHP Version in JetBrains PhpStorm 2022.2.2 - Configured PHP Language Level

Step 01: Change the PHP Version By Clicking on the Configured PHP Language Level Display Indicator in the Status Bar

The quickest and easiest method for changing the PHP level is simply to click the value in the status bar, then change it to the desired PHP level. I’m wanting to utilize PHP 8.1 in my project, so I’ll select that.

How To Change Current Project PHP Version in JetBrains PhpStorm 2022.2.2 - Change PHP Version From Status Bar

Alternate Method – Step 01: Click File > Settings… Menu to Open the Settings Panel

This method is a bit longer than the previous one, but it also lets you change additional settings in your project. You can modify the PHP CLI Interpreter, add include paths, change the PHP runtime or define unchecked exceptions.

How To Change Current Project PHP Version in JetBrains PhpStorm 2022.2.2 - File data-lazy-src=

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. – Mchl Nov 8 ’10 at 9:33

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. – Mchl Nov 8 ’10 at 10:55

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.

Источник

Configure local PHP interpreters

A local PHP interpreter is a PHP engine installed on your computer opposite to a remote PHP interpreter that can be installed on a remote host or in a virtual environment set up in a Vagrant instance , see Configure remote PHP interpreters.

Before you begin, install a PHP engine either as part of an AMP package or separately.

  1. Press Ctrl+Alt+S to open the IDE settings and select PHP .
  2. On the PHP page that opens, click next to the CLI Interpreter list.
  3. In the CLI Interpreters dialog that opens, click in the left-hand pane, then choose Local from the popup menu. If you already have a local interpreter configured in PhpStorm, it is also shown from the menu and the menu item changes to Other Local .
  4. In the right-hand pane of the dialog, specify the PHP interpreter’s settings.
    1. In the Name field, type the identifier to distinguish the interpreter from others, for example, php_installation_ .
    2. Specify the PHP engine installation directory in the PHP executable field. Type the path manually or click and select the relevant folder in the dialog that opens. 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.

    -dxdebug.mode=debug -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.start_upon_error=default For example, if you specify the -dxdebug.start_upon_error=yes directive it will override the default -dxdebug.start_upon_error=default directive and thus switch Xdebug to the Just-In-Time (JIT) mode, see Debug in the Just-In-Time mode for details.

    -dxdebug.remote_enable=1 -dxdebug.remote_host=127.0.0.1 -dxdebug.remote_port=9000 -dxdebug.remote_mode=req For example, if you specify the -dxdebug.remote_mode=jit directive it will override the default -dxdebug.remote_mode=req directive and thus switch Xdebug to the Just-In-Time (JIT) mode, see Debug in the Just-In-Time mode for details.

    • To add a new entry, click . In the new line, that is added to the list, specify the name of the new entry and its value in the Name and Value fields respectively. You can add as many entries as you need, just keep in mind that they will be transformed into a command line with its length limited to 256 characters.
    • To delete an entry, select it in the list and click .
    • To change the order of entries, click or .

    Upon clicking OK , you return to the CLI Interpreters dialog, where the entries are transformed into a command line.

    Switch between configured PHP interpreters on the fly

    1. Press Ctrl+Shift+A and start typing Change PHP interpreter . In the suggestions list, select the Change PHP interpreter action. If necessary, you can assign a keyboard shortcut for this action either directly in the suggestions list by pressing Alt+Enter , or at a later point as described in Keyboard shortcuts.
    2. In the popup menu that opens, select one of the configured local or remote PHP interpreters.

    The selected interpreter will be set as the default project interpreter on the PHP page of the Settings dialog ( Ctrl+Alt+S ). This will also affect configurations that use the default project interpreter (test frameworks’, quality tools’, and run/debug configurations) and commands run in the PhpStorm terminal.

    Источник

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