« Back to Product

Documentation

Visual Studio Code

VisualStudioCode has some useful extensions for module development.

Install Extension for IP-Symcon

A function list has been created in this extension to display it in the source code.

Marketplace

Call up this Link to Marketplace and click on "Install".

Extension browser in VSC

  • Call up "Extensions"
  • Search for "Symcon"
  • Select the "Extension for IP-Symcon" and click on "Install" to install it
  • In the Extensions area under "Installed" -> "Extension for IP-Symcon" should now appear
Configuration of PhpStorm

Download PHP

PHP is required for the extensions "CS Fixer" and "PHPUnit".
Here is a link to download PHP. PHP 8 or higher is recommended.

  • Call up "Settings" by clicking on the cogwheel (Manage).
  • Select "PHP" under "Extensions".
  • There is the item "PHP > Validate: Executable Path" where the "settings.json" can be called.
  • The path to php.exe is now specified after "php.validate.executablePath".
    The "\" must be escaped with a second "\".
"php.validate.executablePath": "Path\\To\\php.exe"

Install CS Fixer

Needed are:

  • The PHAR file, which can be downloaded from this link . Version 3 is supported with PHP 8.
  • A .style folder. It is recommended to include this Repository as a submodule in the own repository
  • The extension to use cs-fixer in Visual Studio Code, which can be downloaded from the Marketplace or subsequently embed directly into Visual Studio Code

Extension browser in VSC

  • Call up "Extensions"
  • Search for "php cs fixer".
  • Select the "php cs fixer" from junstyle and install it by clicking on "Install".
  • The extensions area should now appear under "Installed" -> "php cs fixer".

Configure CS Fixer

  • Call up "Settings" by clicking on the cogwheel (Manage)
  • Select "PHP CS Fixer" under "Extensions"
  • The item "Allow Risky" is set to true
  • Under the item "PHP-cs-fixer: Executable Path" specifies the path to "php-cs-fixer.phar".

Alternatively, these settings can be entered in "settings.json".

"php-cs-fixer.executablePath": "Path\\To\\php-cs-fixer-v3.phar",
    "php-cs-fixer.allowRisky": true

Use CS Fixer

If everything is correctly integrated and set up, the extension can be used. Either by right-clicking in the file to be formatted and selecting Format Document or by pressing the shortcut "Shift+Alt+F".
If the entire project should adopt the style, the following command can be entered via the command line.

php "Path\\To\\php-cs-fixer-v3.phar" fix --config=.style/.php_cs -v --allow-risky=yes

Install PHP Unit

Needed are:

  • PHPUnit's PHAR file, which can be downloaded from this link .
  • A test to run
  • The extension to use PHPUnit in Visual Studio, which can be downloaded from the Marketplace or subsequently embed directly into Visual Studio Code

Extension browser in VSC

  • Call up "Extensions"
  • Search for "PHPUnit".
  • Select the "PHPUnit Test Explorer" and install it by clicking on "Install".
  • The extensions area should now appear under "Installed" -> "PHPUnit Test Explorer" and "Test Explorer UI".

Configure PHP Unit

  • Call up "Settings" by clicking on the cogwheel (Manage)
  • Select "PHPUnit configuration" under "Extensions".
  • At the item "Phpunit: Files" is entered "{test,tests}/*/Test.php".
  • Under the point "Phpunit: PHP" the path to PHP.exe is entered.
  • At the item "Phpunit: Phpunit" the path to the Phpunit Phar file is entered
  • Therefore, under "Phpunit: Args" ["--configuration", "tests/phpunit.xml"] must be entered.

Alternatively, these settings can be entered in "settings.json".

"phpunit.phpunit": "Path\\To\\phpunit-9.5.10.phar",
    "phpunit.args": [
        "--configuration", "tests/phpunit.xml"
    ],
    "phpunit.php": "Path\\To\\php.exe",
    "phpunit.files": "{test,tests}/**/*Test.php",

Now PHPUnit can be used. However, errors can still occur. So the following error can appear:

"PHPUnit requires the "mbstring" extension."
  • Navigate to the folder where "php.exe" is located
  • Look for the "php.ini" file in this folder. If it doesn't exist, search for "php.ini-development" and rename it
  • Open the "php.ini" file in any text editor
  • Search for "mbstring" in the "Dynamic Extensions" section
  • Remove the semicolon in front of "extension=mbstring".
  • Save file
  • Close and reopen Visual Studio Code

Now, another error may occur:

PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring' 
(tried: C:\php\ext\mbstring (Das angegebene Modul wurde nicht gefunden.), )
C:\php\ext\php_mbstring.dll  (Das angegebene Modul wurde nicht gefunden.) in
Unknown on line 0
  • Navigate to the folder where "php.exe" is located
  • Look for the "php.ini" file in this folder. If it doesn't exist, search for "php.ini-development" and rename it
  • Open the "php.ini" file in any text editor
  • Look for "extension_dir" in the "Paths and Directories" section
  • Remove the semicolon in front of "extension_dir = "ext"" which is under "On windows:".
  • Save file
  • Close and reopen Visual Studio Code

Use PHPUnit

Two buttons should now appear above the function with the test. The test is started by clicking on Run.

PhpUnit
Any questions?