2018-02-17 19:53:17 -05:00
|
|
|
|
# Installation
|
|
|
|
|
|
2020-10-26 15:14:48 -04:00
|
|
|
|
The latest version of Psalm requires PHP >= 7.1 and [Composer](https://getcomposer.org/).
|
2018-02-17 19:53:17 -05:00
|
|
|
|
|
|
|
|
|
```bash
|
2018-04-15 10:56:43 -04:00
|
|
|
|
composer require --dev vimeo/psalm
|
|
|
|
|
```
|
|
|
|
|
|
2020-10-03 01:45:58 -04:00
|
|
|
|
Generate a config file:
|
2018-04-15 10:56:43 -04:00
|
|
|
|
|
|
|
|
|
```bash
|
2020-02-17 16:49:54 -05:00
|
|
|
|
./vendor/bin/psalm --init
|
2018-04-15 10:56:43 -04:00
|
|
|
|
```
|
|
|
|
|
|
2020-02-17 16:49:54 -05:00
|
|
|
|
Psalm will scan your project and figure out an appropriate [error level](error_levels.md) for your codebase.
|
2019-02-11 02:38:26 +02:00
|
|
|
|
|
2018-04-15 10:56:43 -04:00
|
|
|
|
Then run Psalm:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
./vendor/bin/psalm
|
2018-02-17 19:53:17 -05:00
|
|
|
|
```
|
2019-03-19 12:08:22 -04:00
|
|
|
|
|
|
|
|
|
Psalm will probably find a number of issues - find out how to deal with them in [Dealing with code issues](dealing_with_code_issues.md).
|
2019-12-18 15:35:18 +00:00
|
|
|
|
|
2020-05-14 14:47:55 +03:00
|
|
|
|
## Installing plugins
|
|
|
|
|
|
|
|
|
|
While Psalm can figure out the types used by various libraries based on the
|
|
|
|
|
their source code and docblocks, it works even better with custom-tailored types
|
|
|
|
|
provided by Psalm plugins.
|
|
|
|
|
|
2021-01-31 02:28:41 +01:00
|
|
|
|
Check out the [list of existing plugins on Packagist](https://packagist.org/?type=psalm-plugin).
|
2020-10-03 10:30:05 -04:00
|
|
|
|
Install them with `composer require --dev <plugin/package> && vendor/bin/psalm-plugin enable <plugin/package>`
|
2020-05-14 14:47:55 +03:00
|
|
|
|
|
|
|
|
|
Read more about plugins in [Using Plugins chapter](plugins/using_plugins.md).
|
|
|
|
|
|
2019-12-18 15:35:18 +00:00
|
|
|
|
## Using the Phar
|
|
|
|
|
|
2021-02-24 22:22:40 +01:00
|
|
|
|
Sometimes your project can conflict with one or more of Psalm’s dependencies. In
|
|
|
|
|
that case you may find the Phar (a self-contained PHP executable) useful.
|
2019-12-18 15:35:18 +00:00
|
|
|
|
|
2021-02-24 22:22:40 +01:00
|
|
|
|
The Phar can be downloaded from Github:
|
2019-12-18 15:35:18 +00:00
|
|
|
|
|
2021-02-24 22:22:40 +01:00
|
|
|
|
```bash
|
|
|
|
|
wget https://github.com/vimeo/psalm/releases/latest/download/psalm.phar
|
|
|
|
|
chmod +x psalm.phar
|
|
|
|
|
./psalm.phar --version
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Alternatively, you can use Composer to install the Phar:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
composer require --dev psalm/phar
|
|
|
|
|
```
|