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

doc: add installation method documentation #10732

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/contributing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Lastly, working to improve static analysis tools will also make you a better PHP

* [Editing callmaps](editing_callmaps.md)
* [Adding a new issue type](adding_issues.md)
* [Packaging Psalm](packaging.md)

## Pull Requests

Expand Down
19 changes: 19 additions & 0 deletions docs/contributing/packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Using a Snapshot Build

To obtain the latest development version of Psalm, a snapshot build can be
downloaded from GitHub at https://github.com/vimeo/psalm/archive/refs/heads/5.x.zip

Snapshot builds typically include only the source code and exclude the `.git`
directory. As a result, Psalm cannot automatically determine its version or
revision when executing `composer install`, since this information is usually
derived from the `git` repository metadata that Composer relies on.

To successfully install Psalm from a snapshot build, it is necessary to
manually specify the version using the `COMPOSER_ROOT_VERSION` environment
variable. This allows Composer to proceed with the installation of Psalm.

The command to do so is as follows:

```bash
COMPOSER_ROOT_VERSION=5.x-dev composer install
```
48 changes: 47 additions & 1 deletion docs/running_psalm/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ While Psalm can figure out the types used by various libraries based on
their source code and docblocks, it works even better with custom-tailored types
provided by Psalm plugins.

Check out the [list of existing plugins on Packagist](https://packagist.org/?type=psalm-plugin).
Check out the [list of existing plugins on Packagist](https://packagist.org/?type=psalm-plugin).
Install them with `composer require --dev <plugin/package> && vendor/bin/psalm-plugin enable <plugin/package>`

Read more about plugins in [Using Plugins chapter](plugins/using_plugins.md).
Expand All @@ -51,3 +51,49 @@ Alternatively, you can use Composer to install the Phar:
```bash
composer require --dev psalm/phar
```
# Alternative Installation Methods

The following methods are known to work for some users, but are **not** officially supported.

## Installing with `composer` globally

```bash
composer global require vimeo/psalm
```

## Installing with `phive`

```bash
phive install psalm
```

## Installing Psalm on Linux using a package manager

Psalm is available across various Linux distributions, each typically equipped
with its own package management system. To install Psalm, refer to the
documentation specific to your distribution's package manager.

### Installation on Nix

For users of Nix, Psalm is readily [available](https://search.nixos.org/packages?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=psalm)
and can be installed or run using several methods.

To run Psalm directly, use the following command:

```bash
nix run github:NixOS/nixpkgs-unstable#php.packages.psalm
```

For an ephemeral shell environment with Psalm, either of the following commands
can be used:

```bash
nix-shell -p php.packages.psalm
```

```bash
nix shell github:NixOS/nixpkgs-unstable#php.packages.psalm
```

Psalm builds on Nix are reproducible, ensuring that executing the same command
on any system yields an identical build of Psalm.