tree-sitter-php
PHP grammar for tree-sitter
What it is and what it does
tree-sitter-php is a language grammar module that provides PHP syntax parsing for the tree-sitter incremental parsing framework. It enables developers to parse PHP code into abstract syntax trees for analysis, transformation, or tooling purposes. The package provides precompiled binaries for major platforms (macOS x86/arm, Linux x86/arm, Windows), reducing installation friction compared to building from source.
The package is part of the broader tree-sitter ecosystem and is actively maintained, with recent commits and no known security vulnerabilities. It requires Python 3.10 or later and has no runtime dependencies beyond the tree-sitter framework itself.
Use it for:
- Build linters or code formatters that analyze PHP syntax trees for style violations or refactoring opportunities.
- Implement static analysis tools that traverse PHP ASTs to detect bugs, security issues, or code smells.
- Create IDE extensions or editor plugins that provide syntax highlighting or navigation for PHP.
- Parse and transform PHP code programmatically for code generation, migration, or automated refactoring.
- Analyze large PHP codebases to extract metrics, dependencies, or architectural patterns.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a PHP language grammar for tree-sitter, enabling incremental parsing and syntax tree analysis of PHP code.
Yes, if you need to parse or analyze PHP code programmatically within the tree-sitter ecosystem. The package is actively maintained, has no security vulnerabilities, uses a permissive MIT license, and medium install friction is acceptable for a compiled grammar. Not necessary if you're not already using tree-sitter or if you only need basic PHP tokenization.
Install
tree-sitter-php on PyPI
pip
pip install tree-sitter-phpuv
uv add tree-sitter-phppoetry
poetry add tree-sitter-phpInstalling tree-sitter-php
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for common platforms (macOS x86/arm, Linux x86/arm, Windows). Requires Python 3.10+. Actively maintained with recent commits and no reported security issues.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install tree-sitter-php
Requires Python 3.10 or later; integration with tree-sitter core library required for actual parsing.
Verify before relying
- How to load and use the grammar binary after installation with tree-sitter bindings.
- Whether precompiled binaries include the PHP grammar or if separate compilation is needed.
- API stability and compatibility guarantees across minor versions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 363 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,316,065/month — #1,755 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tree_sitter_php-0.24.1-cp310-abi3-macosx_10_9_x86_64.whl; tree_sitter_php-0.24.1-cp310-abi3-macosx_11_0_arm64.whl; tree_sitter_php-0.24.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tree_sitter_php-0.24.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; tree_sitter_php-0.24.1-cp310-abi3-musllinux_1_2_x86_64.whl; tree_sitter_php-0.24.1-cp310-abi3-win_amd64.whl; tree_sitter_php-0.24.1-cp310-abi3-win_arm64.whl
Keywords: incremental, parsing, tree-sitter, php
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
tree-sitter-javaProvides a Java language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-pythonProvides a Python grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-bashProvides a tree-sitter grammar for parsing Bash…
permissive · top 1,000 on PyPI
tree-sitter-cProvides a C language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-goProvides a Go language grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-powershellProvides a tree-sitter grammar for parsing…
permissive · top 5,000 on PyPI
tree-sitter-htmlProvides an HTML grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-rubyProvides a Ruby language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-sqlProvides a tree-sitter SQL grammar for parsing…
permissive · top 5,000 on PyPI
phplyphply is a lexer and parser for PHP source code…
permissive · top 15,000 on PyPI