Indexer

The indexer scans your project directory and records meta-information about classes and functions in your project.

The indexer required only for some features (such as Jump to Implementation).

Building the index

It will be automatically enabled when used with the language server but can also be used with RPC if run manually.

Build index and watch for changes

$ phpactor index:build --watch

Build from scratch

$ phpactor index:build --reset

Watching

File watchers are used to keep the index up-to-date.

Several watching systems can be used, by default Phpactor will choose the first supported one:

lsp

Any platform

This watcher depends on file events from the LSP client (e.g. VSCode).

inotifywait

Linux only, react immediately to file changes.

Installation

apt install inotify-tools

watchman

Linux/Mac cross platform, reacts immediately to file changes, see Watchman documentation.

Watchman is the recommended watcher.

Installation:

apt install watchman

find

Linux/Mac/POSIX Poll the system for changes every 5 seconds.

This tool should be installed by default.

php

Any system: Poll system using PHP (slow) every 5 seconds.

Querying from the CLI

You can query the index from the CLI:

$ phpactor index:query "Symfony\\Component\\Console\\Output\\OutputInterface"

Note that this information is primarily intended for the indexer and is not yet intended to provide a true “querying” facility.

Configuration

List the possible configuration options with phpactor config:dump | grep indexer, explanations of some important ones:

Troubleshooting

Inotify: Why isn’t inotifywait used when I’m on Linux?

It may not be installed, on Debian/Ubuntu

$ sudo apt install inotify-tools

Inotify: inotify limit reached

The default number of watchers is quite low by default, try increasing the number of watchers:

$ sudo sysctl fs.inotify.max_user_watches=100000

Note this still may not be sufficient, so increase as necessary, make the change permanent by writing to /etc/sysctl.conf