Skip to content

PHP language server

Sergey Skorik edited this page Sep 11, 2018 · 5 revisions

Preconditions:

  1. Create workspace from the PHP stack with web-php-simple project.
  2. Enable PHP language server in the Installers tab and start the workspace.
  3. Create "index.php" file with content:
<?php include 'lib.php';?>

<?php
echo sayHello("man");
?>
  1. Create "lib.php" file with content:
<?php
function sayHello($name) {
    return "Hello, $name";
}
?>

Testing process

  • Language server initialization
  1. From the project open "index.php" file.
  2. Check Finished language servers initialization, file path '/web-php-simple/index.php' message in the dev-machine console.
  • Autocomplete feature
  1. Open "index.php" file.
  2. Add a new line in line 5 and type $color = "blue";.
  3. Press ENTER button, type "$" and than Ctrl+Space buttons. The color fragment should be offered.
  4. Delete the added lines
  • Find definition feature
  1. Open "index.php" file.
  2. Set cursor to 4:10 position and invoke Assistant -> Find Definition. The "lib.php" file should be opened and sayHello function should be selected.
  3. Close the "lib.php" file. Repeat previous step using F4 key instead of Assistant -> Find Definition invocation.
  • Code validation feature, Comment line
  1. Open "index.php" file.
  2. Move cursor in 4:1 position.
  3. Type any symbol there and check that error marker is appeared. Click on error marker - the proposal widget should be show ; expected message.
  4. Restore content. Error marker should disappear.
  5. Move cursor in line 4 position and comment this line by Ctrl+/ buttons.
  6. Check that text in line 4 was changed from echo sayHello("man"); to //echo sayHello("man");.
  7. Uncomment this line by Ctrl+/ buttons.
  • Hover feature
  1. Open "index.php" file.
  2. Move mouse pointer on position 4:12(sayHello() function).
  3. Wait hover popup is appeared with text <?php function sayHello($name) {.

Find References

  1. Open "index.php" file.
  2. Move mouse pointer on position 4:12.
  3. Start Find References feature by pressing Alt+F7 buttons or from Assistant menu.
  4. Check that Find References panel is opened with /web-php-simple/index.php From:4:6 To:4:14 result in it.

Signature Help

  1. Open "index.php" file.
  2. Add a new line in position 5 and type sayHello.
  3. Type '(' symbol and wait for hover popup with (mixed $name) text.
  4. Delete the added line

Go To Symbol

  1. Open "lib.php" file.
  2. Start Go To Symbol feature by Ctrl+F12 buttons or from Assistant menu.
  3. Wait for Go To Symbol form is opened with next line:
sayHello symbols(1)
  1. Click on it and check that it correctly selected in file.

Find Project Symbol

  1. Open "index.php" file.
  2. Start Find Project Symbol feature by Alt+N buttons or from Assistant menu.
  3. Type say in Find Project Symbol form input.
  4. Wait for sayHello /web-php-simple/lib.php line.
  5. Click on it and check that it correctly selected in file.