A SCIP indexer for PHP projects, written in Rust.
scip-php parses PHP codebases and emits a SCIP index file (index.scip) that enables rich code intelligence features — go-to-definition, find-all-references, hover documentation, and more — in tools like Sourcegraph.
- Indexes PHP classes, interfaces, enums, traits, functions, methods, and properties
- Resolves namespaces and cross-file references using PSR-4 autoloading via
composer.json - Extracts PHPDoc documentation for symbols
- Outputs a standard SCIP protobuf file compatible with Sourcegraph and other SCIP consumers
- Fast: implemented in Rust using the Mago PHP parser
Download a pre-built binary for your platform from the releases page.
Supported platforms:
- Linux (x86_64)
- macOS (aarch64)
- Windows (x86_64)
Requires Rust 1.93 or later.
git clone https://github.com/ArtemisMucaj/scip-php
cd scip-php
cargo build --releaseThe binary will be at target/release/scip-php.
scip-php [PROJECT_ROOT] [-o <OUTPUT>]
Arguments:
| Argument | Description | Default |
|---|---|---|
PROJECT_ROOT |
Path to the PHP project root (must contain a composer.json) |
. |
-o, --output <OUTPUT> |
Output path for the SCIP index file | index.scip |
Example:
# Index the current PHP project
scip-php
# Index a specific project and write output to a custom path
scip-php /path/to/my-php-project -o /tmp/my-project.scipAfter running, the tool reports the number of documents, occurrences, and symbols indexed, along with elapsed time.
- The PHP project must have a
composer.jsonwith aautoload.psr-4section so that scip-php can discover source files and resolve namespaces. - No PHP runtime is required — scip-php is a self-contained binary.
- Project discovery — reads
composer.jsonto find PSR-4 autoload paths and enumerate all.phpfiles. - Parsing — each file is parsed into an AST using the Mago PHP parser.
- Name resolution — namespace imports and fully-qualified names are resolved across the project.
- Indexing — the AST is walked to collect symbol definitions and occurrences (references). PHPDoc comments are extracted for hover documentation.
- Serialization — the collected data is written as a binary SCIP protobuf file.
cargo test --verbosesrc/
main.rs CLI entry point and argument parsing
lib.rs Module declarations
indexer.rs Core AST walking and SCIP emission logic
project.rs PHP project discovery via composer.json
symbol.rs SCIP symbol identifier construction
line_index.rs Byte offset to line/column mapping
tests/
integration_test.rs Integration tests
fixtures/sample-project/ Sample PHP project used by tests
See CHANGELOG.md for release history.
MIT