php language features vs code

Programming Languages

Hundreds of programming languages supported

In Visual Studio Code, we have support for almost every major programming language. Several ship in the box, for example, JavaScript, TypeScript, CSS, and HTML but more rich language extensions can be found in the VS Code Marketplace.

Here are eight of the most popular language extensions:

Go to the Marketplace or use the integrated Extensions view and search for your desired programming language to find snippets, code completion/IntelliSense providers, linters, debuggers, and more.

Note: If you want to change the display language of VS Code (for example, to Chinese), see the Display Language topic.

Language specific documentation

Click on any linked item to get an overview of how to use VS Code in the context of that language. Most language extensions also contain a summary of their core features in their README.

Language features in VS Code

The richness of support varies across the different languages and their extensions:

Changing the language for the selected file

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Tip: You can get the same dropdown by running the Change Language Mode command ( ⌘K M (Windows, Linux Ctrl+K M ) ).

Language identifier

VS Code associates a language mode with a specific language identifier so that various VS Code features can be enabled based on the current language mode.

You can see the list of currently installed languages and their identifiers in the Change Language Mode ( ⌘K M (Windows, Linux Ctrl+K M ) ) dropdown.

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

You can find a list of known identifiers in the language identifier reference.

Adding a file extension to a language

You can add new file extensions to an existing language with the files.associations setting.

IntelliSense ( ⌃Space (Windows, Linux Ctrl+Space ) ) will show you the available language identifiers.

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Next steps

Now you know that VS Code has support for the languages you care about. Read on.

Common questions

Can I contribute my own language service?

Yes you can! Check out the example language server in the VS Code Extension API documentation.

What if I don’t want to create a full language service, can I reuse existing TextMate bundles?

Can I map additional file extensions to a language?

Yes, with the files.associations setting you can map file extensions to an existing language either globally or per workspace.

Here is an example that will associate more file extensions to the PHP language:

You can also configure full file paths to languages if needed. The following example associates all files in a folder somefolder to PHP:

Note that the pattern is a glob pattern that will match on the full path of the file if it contains a / and will match on the file name otherwise.

How do I set the default language for new files?

Using the files.defaultLanguage setting, you can map all new files to a default language. Whenever a new blank file is opened, the editor will be configured for that language mode.

This example will associate new files with the HTML language:

Источник

PHP Programming in VS Code

Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense (code completion), and snippets out of the box and you can add more functionality through community created VS Code extensions.

PHP Extensions

Tip: The extensions shown above are dynamically queried. Click on an extension tile above to read the description and reviews to decide which extension is best for you. See more in the Marketplace.

Tip: The following setting allows to disable the built-in PHP completions in favor of proposals created by installed PHP extensions.

Snippets

Visual Studio Code includes a set of common snippets for PHP. To access these, hit kb(editor.action.triggerSuggest) to get a context specific list.

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Linting

Tip: Using XAMPP? Install the full version of PHP in order to obtain the development libraries.

There are three settings to control the PHP linter:

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

To set the PHP executable path, open your User or Workspace Settings and add the php.validate.executablePath :

Windows

Linux and macOS

Debugging

PHP debugging with XDebug is supported through a PHP Debug extension. Follow the extension’s instructions for configuring XDebug to work with VS Code.

Next Steps

Read on to find out about:

Источник

Как настроить VS Code для разработки на PHP

Visual Studio Code — популярный бесплатный редактор кода. Может с легкостью конкурировать с PhpStorm, ведь он бесплатный и с открытым исходным кодом

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code Так может выглядеть интерфейс редактора после установки расширений

Основные возможности

VS Code имеет большое количество расширений для разработчика. Для установки нового пакета зайдите во вкладку «Расширения», введите название пакета в строке поиска и нажмите кнопку «Установить».

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

EditorConfig для VS Code

PHP Intelephense

В редакторе уже есть поддержка синтаксиса и подсказок стандартных функций языка. Но без специальных дополнений редактор не будет подсказывать пользовательские функции из других частей проекта. Поэтому для поддержки автодополнения, анализа кода, перехода к месту, где создана функция/класс/переменная (с помощью шортката Alt + Click ), используется дополнение PHP Intelephense

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

PHP Debug

При разработке может возникнуть ситуация, когда простых функций отладки и логирования становится недостаточно. Тогда может помочь специальный инструмент — Дебаггер.Для PHP есть расширение xdebug, позволяет расставить точку останова и посмотреть окружение в предполагаемом месте, выполняя код поэтапно либо до следующей точки.

Это настройки для конкретной разработки, когда проект разрабатывается и запускается на одном компьютере, например на вашей рабочей машине

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

PHP Sniffer

В PHP в качестве линтера используется PHP_CodeSniffer.Для его работы необходимо установить глобально сам линтер composer global require «squizlabs/php_codesniffer = *» и расширение PHP Sniffer.

Проверьте, что линтер установился:

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Ярлык для вставки точки с запятой

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Extra

Список расширений, которые могут быть использованы не только для PHP:

GitLens — в VS Code уже встроена поддержка Git. Когда базовых возможностей становится недостаточно, на помощь может придти Gitlens. Например, одна из полезных фич — git blame на в текущей строке.

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Indent Rainbow — разноцветные отступы в коде. ает некорректный отступ. Можно вместо радуги установить оттенки серого.

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Settings Sync — плагин, позволяющий синхронизировать настройку редактора между разными компьютерами. В качестве хранилища используется Github Gists. Все настройки можно скачать, указав нужный файл синхронизации.

Fira Code — моноширинный шрифт, в котором используются лигатуры (объединяет несколько символов в) для общих комбинаций символов в программировании. Визуальная надстройка для более удобного чтения кода.

Источник

PHP in Visual Studio Code

Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense (code completion), and snippets out of the box and you can add more functionality through community-created VS Code extensions.

Linting

Tip: Using XAMPP? Install the full version of PHP in order to obtain the development libraries.

There are three settings to control the PHP linter:

To change the PHP settings, open your User or Workspace Settings ( ⌘, (Windows, Linux Ctrl+, ) ) and type ‘php’ to filter the list of available settings.

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

To set the PHP executable path, select the Edit in settings.json link under PHP > Validate: Executable Path, which will open your user settings.json file. Add the php.validate.executablePath setting with the path to your PHP installation:

Windows:

Linux and macOS:

Snippets

Visual Studio Code includes a set of common snippets for PHP. To access these, hit ⌃Space (Windows, Linux Ctrl+Space ) to get a context-specific list.

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

PHP extensions

There are many PHP language extensions available on the VS Code Marketplace and more are being created. You can search for PHP extensions from within VS Code in the Extensions view ( ⇧⌘X (Windows, Linux Ctrl+Shift+X ) ) then filter the extensions dropdown list by typing ‘php’.

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Disable built-in PHP support

To disable the built-in PHP smart completions in favor of suggestions from an installed PHP extension, uncheck PHP > Suggest: Basic, which sets php.suggest.basic to false in your settings.json file.

Debugging

PHP debugging with XDebug is supported through a PHP Debug extension. Follow the extension’s instructions for configuring XDebug to work with VS Code.

Next steps

Read on to find out about:

Источник

Отладка php в Visual Studio Code (Xdebug, Windows)

В некоторых случаях может возникнуть необходимость отладки приложений на php. Visual Studio code предоставляет такую возможность при условии установки дополнительного расширения PHP Debug (marketplace, github).

Установка PHP Debug

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Установка и настройка Xdebug

PHP Debug использует для отладки Xdebug. Для настройки Xdebug пройдите по ссылке. Предполагается, что на локальной машине уже установлен и настроен сервер apache. Здесь и далее действия указаны для Windows. Можно создать файл, например, test.php содержащий:

Открыть его в браузере и скопировать содержимое страницы в диалоговое окно. Другой способ:

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Кроме этого, добавьте нижеследующие строки. Итоговое добавление будет примерно таким:

Как вы уже, возможно догадались, в данном примере на локальной машине установлен XAMPP.

Примечание: С версией Xdebug 2.5 и выше Visual Studio code не работает. Поэтому выбирайте соответствующий вашей версии php файл *.dll.

Настройка Visual Studio code

Вызовите панель отладки (1) и нажмите на иконку с маленькой шестеренкой (2).

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Настройка PHP Debug на этом окончена.

Отладка php в Visual Studio code

Откройте в браузере ваше приложение\сайт. Откройте папку с приложением в Visual Studio code. Установите в нужных файлах и строках точки остановки. Откройте панель отладки и выберите для запуска отладки команду Listen for Xdebug (1). Нажмите кнопку запуска (2).

php language features vs code. Смотреть фото php language features vs code. Смотреть картинку php language features vs code. Картинка про php language features vs code. Фото php language features vs code

Обновите страницу в браузере и наслаждайтесь.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *