php-lsp/skeleton

The skeleton application for the Language Server Protocol extension

dev-master / 1.x-dev 2024-11-18 05:15 UTC

This package is auto-updated.

Last update: 2024-11-18 05:15:44 UTC


README

About Language Server Protocol

[ALARM] This is not the final version!

LSP is a protocol for interaction with a client using the JSON-RPC 2.0 codec, where arbitrary editors and IDEs act as clients.

The protocol is supported by many clients, such as:

Most Popular Editors:

Most Popular IDE:

This project gives you the opportunity to write your own plugins for any editor or IDE using the PHP language!

Installation

# create an extension application
composer create-project php-lsp/skeleton

# allow build script to run (required once)
chmod +x bin/build

Running Extension Server

Run From Sources

php ./bin/lsp serve App\\Application --port=5007

Run From Code

<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

$app = new \App\Application('dev', true);
$app->listen('tcp://127.0.0.1:5007');

Build And Run (Using Composer)

# build server assembly
composer build

# run server assembly
composer run

Build And Run (Using Binaries)

# build server assembly
./bin/build

# run server assembly
php ./var/prod/build.phar serve App\\Application --port=5007

Running Extension Client

Please note that these are just extension examples. Unification of the assembly without code (JS, Java, C#, etc) modification will come later, perhaps.

VSCode

See client/vscode/package.json to modify the configuration.

  1. Build and run editor:
    # move to vscode workspace
    cd client/vscode
    
    # install dependencies
    npm install
    
    # run client
    code .
  2. Then press F5 (in editor) to run extension