Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include local and global installation instructions in README.md. #639

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 48 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,54 @@ All classes are considered internal and are not subject to semver.

## Installation

The recommended installation method is through [Composer](https://getcomposer.org/).
Simply run

composer require felixfbecker/language-server

and you will get the latest stable release and all dependencies.
Running `composer update` will update the server to the latest non-breaking version.

After installing the language server and its dependencies,
you must parse the stubs for standard PHP symbols and save the index for fast initialization.

composer run-script --working-dir=vendor/felixfbecker/language-server parse-stubs
The recommended installation method is through [Composer](https://getcomposer.org/). Follow the following installation instructions for local or global installation after installing composer on your system.

### Local Installation
Create a directory for php-language-server. Create a composer.json file in it, with the following contents:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea for local installation is that your add this to the composer.json file of your project, where the project is something like https://github.com/felixfbecker/vscode-php-intellisense or some other editor integration or use case for the language server. The directory shouldn't be considered "the directory for php-language-server" because that will be ./vendor/felixfbecker/language-server

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the idea here is that some users will want to try this out without making any changes to their global composer config, and these instructions provide a way of creating a local (perhaps temporary) instance of the language server without touching anything else.

The text editor can then be pointed to the local installation for testing. If it all pans out, the user might move to a global install (or not, as the case may be).

So "local" installation here can be thought of as a self-contained installation, rather than integrating it into another project like vscode-php-intellisense. Perhaps that should be covered as a third case, though?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example of why users might want a separate/self-contained installation is so that they can patch the language server for specific use-cases without affecting their global installation. For instance, modifying the hard-coded set of filename extensions which should be treated as PHP files in a particular project type -- a need that I personally ran into yesterday.


```
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"felixfbecker/language-server": "v5.4.0"
},
"scripts": {
"parse-stubs": "LanguageServer\\ComposerScripts::parseStubs",
"post-update-cmd": "@parse-stubs",
"post-install-cmd": "@parse-stubs"
}
}
```
Then, in the directory, run the following commands:

```
composer require felixfbecker/language-server
```

### Global installation
Before installing php-language-server, make sure your ~/.config/composer/composer.json includes the lines below. The settings apply to all globally installed Composer packages, so proceed with caution. If you do not want to edit your global Composer configuration, see the section for local installation above.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least on my system (Mac with homebrew installed php and composer), the global config is in ~/.composer/composer.json rather than ~/.config/composer/composer.json.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More generally, use $COMPOSER_HOME if it's set. Refer to https://getcomposer.org/doc/03-cli.md#composer-home

If it's not set, note that a hard-coded fallback could be error-prone, as the default value is quite variable depending on the OS (and version thereof) you're running.


```
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"felixfbecker/language-server": "v5.4.0"
},
"scripts": {
"parse-stubs": "LanguageServer\\ComposerScripts::parseStubs",
"post-update-cmd": "@parse-stubs",
"post-install-cmd": "@parse-stubs"
}
}

```
After editing your composer.json, you can install felixfbecker/php-language-server.

```
composer global require felixfbecker/language-server
```

## Running

Expand Down