PHP

About

PHP is a popular general-purpose scripting language that is especially suited to web development.

Installation

Change enable from False to True in the php section (cf module installation).

vscode-anywhere:
    php:
        enabled: True

You can also take a look at the VSCode-Anywhere php module configuration.

For more details read the official documentation.

Requirements

No requirements.

VSCode

VSCode extensions

bmewburn.vscode-intelephense-client

This extension provides PHP IntelliSense for Visual Studio Code.

felixfbecker.php-debug

This extension is a PHP debugger adapter for Visual Studio Code.

junstyle.php-cs-fixer

This extension provides PHP CS Fixer command.

This extension permits to format the PHP code.

ikappas.phpcs

This extension is a linter plugin for Visual Studio Code that provides an interface to phpcs.

MehediDracula.php-namespace-resolver

PHP Namespace Resolver can import and expand your class. You can also sort your imported classes by line length or in alphabetical order.

brapifra.phpserver

This extension allows starting / stopping a PHP server in your current workspace (or subfolder).

ecodes.vscode-phpmd

This extension analyzes your PHP source code on save with PHP mess detector.

recca0120.vscode-phpunit

This extension allows to run PHP tests.

VSCode settings

Global settings

{
    "php.suggest.basic": false,
    "[php]": {
        "editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
    }
}

Windows settings

{
    "php.validate.executablePath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\php\\current\\php.exe",
    "phpserver.phpPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\php\\current\\php.exe",
    "php-cs-fixer.executablePathWindows": "C:\\VSCode-Anywhere\\apps\\scoop\\\persist\\composer\\install\\vendor\\bin\\php-cs-fixer.bat",
    "phpcs.executablePath": "C:\\VSCode-Anywhere\\apps\\scoop\\persist\\composer\\install\\vendor\\bin\\phpcs.bat",
    "phpunit.php": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\php\\current\\php.exe",
    "phpunit.phpunit": "C:\\VSCode-Anywhere\\apps\\scoop\\persist\\composer\\install\\vendor\\bin\\phpunit.bat"
}

Assuming you have installed in the default directory C:\VSCode-Anywhere.

Linux settings

{
    "php.validate.executablePath": "/home/linuxbrew/.linuxbrew/bin/php",
    "phpserver.phpPath": "/home/linuxbrew/.linuxbrew/bin/php",
    "php-cs-fixer.executablePath": "/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/php/composer/install/vendor/bin/php-cs-fixer",
    "phpcs.executablePath": "/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/php/composer/install/vendor/bin/phpcs",
    "phpunit.php": "/home/linuxbrew/.linuxbrew/bin/php",
    "phpunit.phpunit": "/home/myuser/VSCode-Anywhere/apps/vscode-anywhere/php/composer/install/vendor/bin/phpunit"
}

Assuming you have installed in the directory /home/myuser/VSCode-Anywhere.

VSCode keybindings

No keybindings.

Software

Windows software

scoop

Linux software

nix

MacOS software

brew

Documentation

VSCode-Anywhere

Environment

Windows environment

PATH: C:\VSCode-Anywhere\apps\scoop\apps\composer\current\home\vendor\bin
COMPOSER_HOME: C:\VSCode-Anywhere\apps\scoop\persist\composer\home
PHP_INI_SCAN_DIR: C:\VSCode-Anywhere\apps\scoop\apps\php\current\cli;C:\VSCode-Anywhere\apps\scoop\apps\php\current\cli\conf.d

Assuming you have installed in the default directory C:\VSCode-Anywhere.

Linux environment

    PATH: /home/myuser/VSCode-Anywhere/apps/vscode-anywhere/php/composer/home/vendor/bin
    COMPOSER_HOME: /home/myuser/VSCode-Anywhere/apps/vscode-anywhere/php/composer/home

Assuming you have installed in the directory /home/myuser/VSCode-Anywhere.

Specific settings

extensions

Allow to manage PHP extensions in php.ini file.

This is a simple list of extensions to enable in PHP.

  • Windows

  vscode-anywhere:
    php:
      extensions:
        - openssl

composer

Allow installing packages with composer.

  • pkgs: name of the packages to install

    • enabled: True to enable, False to skip (default to False)

    • version: the version of the composer package

  • opts

opts is not mandatory but allows to pass additional arguments.

Extra args can be arguments described in the Saltstack composer states or can be global Saltstack arguments.

Global opts packages settings:

  • composer:pkgs:opts:global: allow passing arguments to all composer packages when installing, updating, or uninstalling a package

  • pm:pkgs:opts:install: allow passing arguments to all composer packages when installing a package (cf states.composer.installed)

  • composer:pkgs:opts:update: allow passing arguments to all composer packages when updating a package (cf states.composer.update)

  • composer:pkgs:opts:uninstall: not yet implemented

Specific opts packages settings:

  • composer:pkgs:<mypkg>:opts:global: allow passing arguments to <mypkg> composer package when installing, updating, or uninstalling the package

  • composer:pkgs:<mypkg>:opts:install: allow to pass arguments to <mypkg> composer packages when installing the package (cf states.composer.installed)

  • composer:pkgs:<mypkg>:opts:update: allow to pass arguments to <mypkg> composer packages when updating the package (cf states.composer.update)

  • composer:pkgs:<mypkg>:opts:uninstall: not yet implemented

  • global:

vscode-anywhere:
  php:
    enabled: True
    composer:
      opts:
        global: {}
        install: {}
        update: {}
      pkgs:
        squizlabs/php_codesniffer:
          enabled: True
          version: '@stable'
        phpunit/phpunit:
          enabled: True
          version: '@stable'
        friendsofphp/php-cs-fixer:
          enabled: True
          version: '@stable'
  • Windows:

vscode-anywhere:
  php:
    enabled: True
    composer:
      json: C:\VSCode-Anywhere\apps\scoop\persist\composer\install\composer.json
      opts:
        global:
          php: C:\VSCode-Anywhere\apps\scoop\scoop\apps\php\current\php.exe
          composer: C:\VSCode-Anywhere\apps\scoop\apps\composer\current\composer.phar
          composer_home: C:\VSCode-Anywhere\apps\scoop\persist\composer\home
          env:
            - PHP_INI_SCAN_DIR: C:\VSCode-Anywhere\apps\scoop\apps\php\current\cli;C:\VSCode-Anywhere\apps\scoop\apps\php\current\cli\conf.d
        install: {}
        update: {}

Assuming you have installed in the default directory C:\VSCode-Anywhere.

  • Linux:

vscode-anywhere:
  php:
    composer:
      json: /home/myuser/VSCode-Anywhere/apps/vscode-anywhere/php/composer/install/composer.json
      opts:
        global:
          composer: /home/linuxbrew/.linuxbrew/bin/composer
          composer_home: /home/myuser/VSCode-Anywhere/apps/vscode-anywhere/php/composer/home
        install: {}
        update: {}

Assuming you have installed in the directory /home/myuser/VSCode-Anywhere.

pecl

PECL allows to install php extensions.

  • pkgs: name of the extension to install

    • enabled: True to enable, False to skip (default to False)

    • version: the version of the pecl extension

  • opts

opts is not mandatory but allows to pass additional arguments.

Extra args can be arguments described in the Saltstack pecl states or can be global Saltstack arguments.

Global opts packages settings:

  • pecl:pkgs:opts:global: allow passing arguments to all pecl packages when installing, updating, or uninstalling a package

  • pm:pkgs:opts:install: allow passing arguments to all pecl packages when installing a package (cf states.pecl.installed)

  • pecl:pkgs:opts:update: not yet implemented

  • pecl:pkgs:opts:uninstall: not yet implemented

Specific opts packages settings:

  • pecl:pkgs:<mypkg>:opts:global: allow passing arguments to <mypkg> pecl package when installing, updating, or uninstalling the package

  • pecl:pkgs:<mypkg>:opts:install: allow passing arguments to <mypkg> pecl packages when installing the package (cf states.pecl.installed)

  • pecl:pkgs:<mypkg>:opts:update: not yet implemented

  • pecl:pkgs:<mypkg>:opts:uninstall: not yet implemented

Replace <mypkg> by the name of the package to install.

  • global:

vscode-anywhere:
  php:
    enabled: True
    pecl:
      opts:
        global: {}
        install: {}
        update: {}
      pkgs: {}
  • Linux:

vscode-anywhere:
  php:
    enabled: True
    pecl:
      pkgs:
        xdebug:
          enabled: True
          version: null
          opts:
            install: {}
            update: {}
            uninstall: {}

Last updated